[IMP] mail: more robust model/record passing

bzr revid: odo@openerp.com-20110909155517-0jhk34b0ka2azxgs
This commit is contained in:
Olivier Dony 2011-09-09 17:55:17 +02:00
parent 57ce728cf5
commit 186a66ba2d
2 changed files with 12 additions and 1 deletions

View File

@ -85,6 +85,16 @@ class mail_compose_message(osv.osv_memory):
if vals:
for field in fields:
result.update({field : vals.get(field, False)})
# link to model and record if not done yet
if not result.get('model') or not result.get('res_id'):
active_model = context.get('active_model')
res_id = context.get('active_id')
if active_model and active_model not in (self._name, 'mail.message'):
result['model'] = active_model
if res_id:
result['res_id'] = res_id
# Try to provide default email_from if not specified yet
if not result.get('email_from'):
current_user = self.pool.get('res.users').browse(cr, uid, uid, context)

View File

@ -8,7 +8,8 @@
<field name="arch" type="xml">
<form string="Compose Email">
<group col="6" colspan="4">
<field name="model" invisible="context.get('active_model',False)"/>
<field name="model" invisible="1"/>
<field name="res_id" invisible="1"/>
<field name='filter_id' invisible="context.get('active_model',False)"/>
<field name="email_from" colspan="4" required="1"/>
<field name="email_to" colspan="4" required="1"/>