In OpenERP first we will create the function and then create js file. After this the no Google doc were associated with a record, with the aim to create one then no config is associated with the res_model, and hence it will result a blank text document with a default name is created.
Use this function given below
def drive_config(self, cr, uid, res_model, res_id, context=None):
if not res_id:
raise UserError(_("Creating google drive may only be done by one at a time."))
config_ids = self.search(cr, uid, [('model_id', '=', res_model)], context=context)
configs = []
for config in self.browse(cr, uid, config_ids, context=context):
if config.filter_id:
if (config.filter_id.user_id and config.filter_id.user_id.id != uid):
continue
domain = [('id', 'in', [res_id])] + eval(config.filter_id.domain)
local_context = context and context.copy() or {}
local_context.update(eval(config.filter_id.context))
google_doc_configs = self.pool.get(config.filter_id.model_id).search(cr, uid, domain, context=local_context)
if google_doc_configs:
configs.append({'id': config.id, 'name': config.name})
else:
configs.append({'id': config.id, 'name': config.name})
return configs
0 Comment(s)