[IMP]Putting a domain of filter to see only filters of the choosen model.
authorDharti Ratani (Open ERP) <dhr@tinyerp.com>
Mon, 4 Mar 2013 05:20:58 +0000 (10:50 +0530)
committerDharti Ratani (Open ERP) <dhr@tinyerp.com>
Mon, 4 Mar 2013 05:20:58 +0000 (10:50 +0530)
bzr revid: dhr@tinyerp.com-20130304052058-fzs7a6ct9d1xb5so

addons/google_docs/google_docs.py
addons/google_docs/res_config_user_view.xml

index e507ce3..73f4bca 100644 (file)
@@ -182,6 +182,17 @@ 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):
+        res = {'domain':{'filter_id':[]}}
+        if model_id:
+            model_name = self.pool.get('ir.model').read(cr, uid, model_id, ['model'])
+            if model_name:
+                mod_name = model_name['model']
+                res['domain'] = {'filter_id': [('model_id', '=', mod_name)]}
+        else:
+            res['value'] = {'filter_id': False}
+        return res
+
     _defaults = {
         'name_template': 'gdoc_%(name)s',
     }
index de6f140..40d4cd9 100644 (file)
@@ -21,7 +21,7 @@
             <field name="arch" type="xml">
                 <form string="Google Drive Configuration" version="7.0">
                 <group>
-                    <field name="model_id"/>
+                    <field name="model_id" on_change="onchange_model_id(model_id)"/>
                     <label for='filter_id'/>
                     <div>
                         <field name='filter_id'/>