From 3f72a8fab61667505c9988f810c110493d70529f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 7 Dec 2018 13:59:59 +0000 Subject: [PATCH] [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 --- addons/purchase/i18n/purchase.pot | 2 ++ addons/purchase/models/purchase.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/addons/purchase/i18n/purchase.pot b/addons/purchase/i18n/purchase.pot index 659b6bbbeca..a994f6a8a6f 100644 --- a/addons/purchase/i18n/purchase.pot +++ b/addons/purchase/i18n/purchase.pot @@ -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 "" diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 9b13a39b6e3..e72b29d98e4 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -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',