[IMP] google_docs : Made changes as per the review of RPA on 21th march
bzr revid: rpr@tinyerp.com-20130322122859-2s1wd5tba9u58g5f
This commit is contained in:
parent
a1dbd86111
commit
f449ab66d9
|
@ -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()
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
<field name="name">Sales Department</field>
|
||||
<field name="model_id">crm.lead</field>
|
||||
<field name="domain">[['section_id', '=', 1]]</field>
|
||||
<field name="context">{'lang': 'en_US', 'tz': 'Europe/Brussels', 'uid': 1}</field>
|
||||
<field name="context">{'lang': 'en_US', 'tz': 'Europe/Brussels'}</field>
|
||||
<field name="user_id" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- template demo -->
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<tree string="Google Drive Configuration">
|
||||
<field name="name"/>
|
||||
<field name="model_id"/>
|
||||
<field name="name_template"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -23,7 +22,7 @@
|
|||
<form string="Google Drive Configuration" version="7.0">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="model_id" on_change="onchange_model_id(model_id,filter_id)"/>
|
||||
<field name="model_id" on_change="onchange_model_id(model_id)"/>
|
||||
<label for='filter_id'/>
|
||||
<div>
|
||||
<field name='filter_id'/>
|
||||
|
@ -52,13 +51,15 @@
|
|||
</record>
|
||||
|
||||
<record model='ir.actions.act_window' id='action_google_docs_users_config'>
|
||||
<field name='name'>Models configuration</field>
|
||||
<field name='name'>Google Drive Templates</field>
|
||||
<field name='res_model'>google.docs.config</field>
|
||||
<field name='type'>ir.actions.act_window</field>
|
||||
<field name='view_type'>form</field>
|
||||
<field name='view_id' ref='view_google_docs_config_tree'/>
|
||||
<field name="help" type="html">
|
||||
<p>
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to add a new template.
|
||||
</p><p>
|
||||
Link your first Google document to OpenERP documents.
|
||||
You can use it to control the quality of your product in a spreadsheet or
|
||||
review the delivery checklist for each delivery order in a foreign country
|
||||
|
@ -83,6 +84,6 @@
|
|||
</record>
|
||||
|
||||
<menuitem name='Google Drive configuration' id='menu_gdocs_config' parent='base.menu_administration'/>
|
||||
<menuitem name='Template Configuration' id='menu_gdocs_model_config' parent='menu_gdocs_config' action='action_google_docs_users_config'/>
|
||||
<menuitem id='menu_gdocs_model_config' parent='menu_gdocs_config' action='action_google_docs_users_config'/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue