[REF] sale: improve usage of composer mixin in order cancel
We can call ``_render_field`` on template model directly. In this commit we also add the dynamic language computation through ``_compute_lang``. It will use the field defined in template. Task-2710804 (Mail: Clean MailThread API) Part-of: odoo/odoo#106072
This commit is contained in:
@@ -60,26 +60,23 @@ class SaleOrderCancel(models.TransientModel):
|
||||
|
||||
@api.depends('order_id')
|
||||
def _compute_subject(self):
|
||||
for wizard in self:
|
||||
if wizard.template_id:
|
||||
wizard.subject = self.sudo()._render_template(
|
||||
wizard.template_id.subject,
|
||||
'sale.order',
|
||||
[wizard.order_id.id],
|
||||
options={'post_process': True},
|
||||
)[wizard.order_id.id]
|
||||
for wizard_su in self.filtered('template_id').sudo():
|
||||
wizard_su.subject = wizard_su.template_id._render_field(
|
||||
'subject',
|
||||
[wizard_su.order_id.id],
|
||||
compute_lang=True,
|
||||
options={'post_process': True},
|
||||
)[wizard_su.order_id.id]
|
||||
|
||||
@api.depends('order_id')
|
||||
def _compute_body(self):
|
||||
for wizard in self:
|
||||
if wizard.template_id:
|
||||
wizard.body = self.sudo()._render_template(
|
||||
wizard.template_id.body_html,
|
||||
'sale.order',
|
||||
[wizard.order_id.id],
|
||||
options={'post_process': True},
|
||||
engine='qweb',
|
||||
)[wizard.order_id.id]
|
||||
for wizard_su in self.filtered('template_id').sudo():
|
||||
wizard_su.body = wizard_su.template_id._render_field(
|
||||
'body_html',
|
||||
[wizard_su.order_id.id],
|
||||
compute_lang=True,
|
||||
options={'post_process': True},
|
||||
)[wizard_su.order_id.id]
|
||||
|
||||
def action_send_mail_and_cancel(self):
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user