[FIX] purchase: View RFQ button

- Create a RFQ
- Send it to the customer

The email sent contains a 'View Purchase Order' button instead of 'View
Request for Quotation'.

We make use of the previous commit to correct the issue.

opw-1915230
This commit is contained in:
Nicolas Martinelli
2018-12-10 13:27:20 +00:00
parent 8cd7de2204
commit 3f72a8fab6
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -1483,8 +1483,10 @@ msgid "Reporting"
msgstr ""
#. module: purchase
#: code:addons/purchase/models/purchase.py:276
#: model:ir.actions.report,name:purchase.report_purchase_quotation
#: model_terms:ir.ui.view,arch_db:purchase.report_purchasequotation_document
#, python-format
msgid "Request for Quotation"
msgstr ""
+16
View File
@@ -264,6 +264,22 @@ class PurchaseOrder(models.Model):
'force_email': True,
'mark_rfq_as_sent': True,
})
# In the case of a RFQ or a PO, we want the "View..." button in line with the state of the
# object. Therefore, we pass the model description in the context, in the language in which
# the template is rendered.
lang = self.env.context.get('lang')
if {'default_template_id', 'default_model', 'default_res_id'} <= ctx.keys():
template = self.env['mail.template'].browse(ctx['default_template_id'])
if template and template.lang:
lang = template._render_template(template.lang, ctx['default_model'], ctx['default_res_id'])
self = self.with_context(lang=lang)
if self.state in ['draft', 'sent']:
ctx['model_description'] = _('Request for Quotation')
else:
ctx['model_description'] = _('Purchase Order')
return {
'name': _('Compose Email'),
'type': 'ir.actions.act_window',