diff options
| author | Turkesh Patel (Open ERP) <tpa@tinyerp.com> | 2014-01-22 12:56:03 +0530 |
|---|---|---|
| committer | Turkesh Patel (Open ERP) <tpa@tinyerp.com> | 2014-01-22 12:56:03 +0530 |
| commit | 5c97da019a198a72d2f4d4affc7d99deb3a0cb7e (patch) | |
| tree | 6ae047553291b7021b50d69517b03b61e2cb89a1 | |
| parent | 7ca3383659ebef07a7531cb157cf7098efcb0f62 (diff) | |
[IMP] improved code to post send mail in chatter also
bzr revid: tpa@tinyerp.com-20140122072603-wik5q5nw49mp562h
| -rw-r--r-- | addons/account_product_template/account_product.py | 14 | ||||
| -rw-r--r-- | addons/account_product_template/account_product_view.xml | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/addons/account_product_template/account_product.py b/addons/account_product_template/account_product.py index 685d611b65d..950357658b2 100644 --- a/addons/account_product_template/account_product.py +++ b/addons/account_product_template/account_product.py @@ -30,9 +30,19 @@ class account_invoice(osv.Model): _inherit = 'account.invoice' def invoice_validate(self, cr, uid, ids, context=None): + if context is None: + context = {} + mail_obj = self.pool.get('mail.compose.message') + res = super(account_invoice, self).invoice_validate(cr, uid, ids, context=context) for line in self.browse(cr, uid, ids[0], context=context).invoice_line: if line.product_id.email_template_id: - self.pool.get('email.template').send_mail(cr, uid, line.product_id.email_template_id.id, ids[0], force_send=True, raise_exception=True, context=context) - return super(account_invoice, self).invoice_validate(cr, uid, ids, context=context) + message_wiz_id = mail_obj.create(cr, uid, { + 'model': 'account.invoice', + 'res_id': ids[0], + 'template_id': line.product_id.email_template_id.id, + 'body': line.product_id.email_template_id.body_html + }, context=context) + mail_obj.send_mail(cr, uid, [message_wiz_id], context=context) + return res # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_product_template/account_product_view.xml b/addons/account_product_template/account_product_view.xml index 8265ffef88d..f1476ac05e6 100644 --- a/addons/account_product_template/account_product_view.xml +++ b/addons/account_product_template/account_product_view.xml @@ -8,7 +8,7 @@ <field name="inherit_id" ref="product.product_normal_form_view"/> <field name="arch" type="xml"> <field name="list_price" position="after"> - <field name="email_template_id" domain="[('model','=','product.product')]"/> + <field name="email_template_id" domain="[('model','=','account.invoice')]"/> </field> </field> </record> |
