[IMP]Changed the demo data for filter and changed the name of the newly created attachment

bzr revid: dhr@tinyerp.com-20130318114403-uifxi4p9nlkbac9r
This commit is contained in:
Dharti Ratani (Open ERP) 2013-03-18 17:14:03 +05:30
parent ea53f4fbf6
commit 7ba1c00149
3 changed files with 13 additions and 12 deletions

View File

@ -36,7 +36,7 @@
'demo': [
'google_docs_demo.xml'
],
'depends': ['google_base_account','crm','document'],
'depends': ['google_base_account','crm'],
'description': """
Integrate Google document with OpenERP.
=======================================

View File

@ -111,7 +111,7 @@ class google_docs_ir_attachment(osv.osv):
# 'title': title,
# 'url': gdocs_resource.get_alternate_link().href}
def copy_gdoc(self, cr, uid, res_model, res_id, name_gdocs,name, gdoc_template_id, context=None):
def copy_gdoc(self, cr, uid, res_model, res_id, name_gdocs, gdoc_template_id, context=None):
'''
copy an existing document in google docs
:param res_model: the object for which the google doc is created
@ -134,7 +134,7 @@ class google_docs_ir_attachment(osv.osv):
'res_model': res_model,
'res_id': res_id,
'type': 'url',
'name': name,
'name': name_gdocs,
'url': copy_resource.get_alternate_link().href
}, context=context)
return copy_resource.resource_id.text
@ -190,21 +190,23 @@ class google_docs_ir_attachment(osv.osv):
# check if a model is configured with a template
if config_ids:
name_gdocs = action.name_template
print 'name_gdocss',name_gdocs
try:
name_gdocs = name_gdocs % model_fields_dic
if name_gdocs.find('model')!=-1:
name_gdocs = name_gdocs.replace('model',action.model_id.name)
if name_gdocs.find('filter')!=-1:
name_gdocs = name_gdocs.replace('filter',action.filter_id.name)
name_gdocs = name_gdocs % model_fields_dic
if action.filter_id:
name_gdocs = name_gdocs.replace('filter',action.filter_id.name)
else:
name_gdocs = name_gdocs.replace('_filter',"")
except:
raise osv.except_osv(_('Key Error!'), _("Your Google Doc Name Pattern's key does not found in object."))
attach_ids = self.search(cr, uid, [('res_model','=',res_model),('name','=',action.name),('res_id','=',res_id)])
attach_ids = self.search(cr, uid, [('res_model','=',res_model),('name','=',name_gdocs),('res_id','=',res_id)])
if not attach_ids:
google_template_id = action.gdocs_resource_id
self.copy_gdoc(cr, uid, action.model_id.model, res_id, name_gdocs, action.name, google_template_id, context=context)
attach_ids = self.search(cr, uid, [('res_model','=',res_model),('name','=',action.name),('res_id','=',res_id)])
self.copy_gdoc(cr, uid, action.model_id.model, res_id, name_gdocs, google_template_id, context=context)
attach_ids = self.search(cr, uid, [('res_model','=',res_model),('name','=',name_gdocs),('res_id','=',res_id)])
attachments = self.browse(cr, uid, attach_ids, context)[0]
attachment['url'] = attachments.url
return attachment

View File

@ -4,10 +4,9 @@
<!-- filter demo -->
<record id="filter_crm" model="ir.filters">
<field name="name">Sales Team</field>
<field name="name">Sales Department</field>
<field name="model_id">crm.lead</field>
<field name="is_default">False</field>
<field name="domain">[['section_id', 'ilike', 'sales department']]</field>
<field name="domain">[['section_id', '=', 1]]</field>
<field name="context">{'lang': 'en_US', 'tz': 'Europe/Brussels', 'uid': 1}</field>
</record>