diff options
| author | Rajesh Prajapati (OpenERP) <rpr@tinyerp.com> | 2013-03-22 17:58:59 +0530 |
|---|---|---|
| committer | Rajesh Prajapati (OpenERP) <rpr@tinyerp.com> | 2013-03-22 17:58:59 +0530 |
| commit | f449ab66d9224a7f6aa9e11ded9959191e0bd218 (patch) | |
| tree | 06c93349c569ab56762c660f0490e718baaca739 /addons/google_docs/google_docs.py | |
| parent | a1dbd861113dc7cb9bb7f90a1c82936c332f70e0 (diff) | |
[IMP] google_docs : Made changes as per the review of RPA on 21th march
bzr revid: rpr@tinyerp.com-20130322122859-2s1wd5tba9u58g5f
Diffstat (limited to 'addons/google_docs/google_docs.py')
| -rw-r--r-- | addons/google_docs/google_docs.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/addons/google_docs/google_docs.py b/addons/google_docs/google_docs.py index d487d31c0d6..f88d408b253 100644 --- a/addons/google_docs/google_docs.py +++ b/addons/google_docs/google_docs.py @@ -235,7 +235,7 @@ class config(osv.osv): return result _columns = { - 'name' : fields.char('Name', required=True, size=1024), + 'name' : fields.char('Template Name', required=True, size=1024), 'model_id': fields.many2one('ir.model', 'Model', required=True), 'filter_id' : fields.many2one('ir.filters', 'Filter'), 'gdocs_template_url': fields.char('Template URL', required=True, size=1024), @@ -243,14 +243,10 @@ class config(osv.osv): 'name_template': fields.char('Google Drive Name Pattern', size=64, help='Choose how the new google drive will be named, on google side. Eg. gdoc_%(field_name)s', required=True), } - def onchange_model_id(self, cr, uid, ids, model_id, filter_id, context=None): + def onchange_model_id(self, cr, uid, ids, model_id, context=None): res = {'domain':{'filter_id':[]}} if model_id: model_name = self.pool.get('ir.model').read(cr, uid, model_id, ['model']) - if filter_id: - filter = self.pool.get('ir.filters').read(cr, uid, filter_id, ['model_id']) - if not model_name['model'] == filter['model_id']: - raise osv.except_osv(_('Warning!'), _('Filter does not match with selected Model!')) if model_name: mod_name = model_name['model'] res['domain'] = {'filter_id': [('model_id', '=', mod_name)]} @@ -262,4 +258,20 @@ class config(osv.osv): 'name_template': '%(name)s_model_filter_gdoc', } + def _check_model_id(self, cr, uid, ids, context=None): + pool_id = self.browse(cr, uid, ids[0], context=context) + model_id = pool_id.model_id.id + filter_id = pool_id.filter_id.id + if model_id: + model_name = self.pool.get('ir.model').read(cr, uid, model_id, ['model']) + if filter_id: + filter = self.pool.get('ir.filters').read(cr, uid, filter_id, ['model_id']) + if model_name['model'] != filter['model_id']: + return False + return True + + _constraints = [ + (_check_model_id, 'The model or filter chosen have not matched.', ['model_id','filter_id']), + ] + config() |
