Browse Source

base_export_email : add email_template sample

pull/115/head
Laetitia Gangloff 10 years ago
parent
commit
2bbba688a7
  1. 3
      base_export_email/__openerp__.py
  2. 18
      base_export_email/ir_actions.py
  3. 12
      base_export_email/ir_actions_data.xml
  4. 2
      base_export_email/ir_actions_view.xml

3
base_export_email/__openerp__.py

@ -44,7 +44,8 @@ Example of use : in a cron for a periodic export of some data
to see the evolution.
""",
"data": ["ir_actions.xml"],
"data": ["ir_actions_view.xml",
"ir_actions_data.xml"],
"demo": [],
"test": [],
"active": False,

18
base_export_email/ir_actions.py

@ -54,8 +54,21 @@ class actions_server(orm.Model):
'Export Formats'),
}
def get_email_template(self, cr, uid, context=None):
email_template_id = 0
try:
model_data_obj = self.pool['ir.model.data']
email_template_id = model_data_obj.get_object_reference(
cr, uid, 'base_export_email', 'export_data_email_template')[1]
except ValueError:
pass
return email_template_id
_defaults = {'fields_to_export': '[]',
'export_format': 'csv'}
'export_format': 'csv',
'email_template_id': lambda self, cr, uid, c:
self.get_email_template(cr, uid, context=c),
}
def onchange_model_id(self, cr, uid, ids, model_id, context=None):
"""
@ -63,7 +76,6 @@ class actions_server(orm.Model):
"""
data = {'model': False,
'filter_id': False,
'email_template_id': False,
'saved_export_id': False}
if model_id:
model = self.pool['ir.model'].browse(cr, uid, model_id,
@ -104,7 +116,7 @@ class actions_server(orm.Model):
mail_compose = self.pool['mail.compose.message']
values = mail_compose.onchange_template_id(
cr, uid, 0, action.email_template_id, 'comment',
action.model, 0, context=context)['value']
'ir.actions.server', action.id, context=context)['value']
values['partner_ids'] = [
(4, partner_id) for partner_id in values.pop('partner_ids',
[])

12
base_export_email/ir_actions_data.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="export_data_email_template" model="email.template">
<field name="name">Export data sample</field>
<field name="subject">Export data for ${object.model}</field>
<field name="model_id" ref="base.model_ir_actions_server" />
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[<div></div>]]></field>
</record>
</data>
</openerp>

2
base_export_email/ir_actions.xml → base_export_email/ir_actions_view.xml

@ -31,7 +31,7 @@
<field name="export_format" attrs="{'required':[('state','=','export_email')]}"/>
<field name="filter_id" domain="[('model_id','=',model)]"/>
<field name="email_template_id" attrs="{'required':[('state','=','export_email')]}"
domain="[('model_id', '=', model_id)]"/>
domain="[('model_id.model', '=', 'ir.actions.server')]"/>
<field name ="fields_to_export" attrs="{'required': [('state', '=', 'export_email'), ('saved_export_id', '=', False)]}" />
<field name ="saved_export_id" attrs="{'required': [('state', '=', 'export_email'), ('fields_to_export', '=', False)]}"
domain="[('resource','=',model)]"/>
Loading…
Cancel
Save