[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:
@@ -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 ""
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user