[IMP] sale_quotation_builder: Convert onchanges into compute method

This commit is contained in:
Yannick Tivisse
2021-12-23 15:30:23 +01:00
committed by Victor Feyens
parent 9e99a9df46
commit 6bf1d1bd9a
@@ -8,16 +8,17 @@ from odoo.tools.translate import html_translate
class SaleOrder(models.Model):
_inherit = 'sale.order'
website_description = fields.Html('Website Description', sanitize_attributes=False, translate=html_translate, sanitize_form=False)
website_description = fields.Html(
'Website Description', sanitize_attributes=False, translate=html_translate, sanitize_form=False,
compute='_compute_website_description', store=True, readonly=False)
# YTI TODO: This should be converted
@api.onchange('partner_id')
def onchange_update_description_lang(self):
if not self.sale_order_template_id:
return
else:
template = self.sale_order_template_id.with_context(lang=self.partner_id.lang)
self.website_description = template.website_description
@api.depends('partner_id', 'sale_order_template_id')
def _compute_website_description(self):
for order in self:
if not order.sale_order_template_id:
continue
template = order.sale_order_template_id.with_context(lang=order.partner_id.lang)
order.website_description = template.website_description
def _compute_line_data_for_template_change(self, line):
vals = super(SaleOrder, self)._compute_line_data_for_template_change(line)
@@ -29,14 +30,6 @@ class SaleOrder(models.Model):
vals.update(website_description=option.website_description)
return vals
@api.onchange('sale_order_template_id')
def onchange_sale_order_template_id(self):
ret = super(SaleOrder, self).onchange_sale_order_template_id()
if self.sale_order_template_id:
template = self.sale_order_template_id.with_context(lang=self.partner_id.lang)
self.website_description = template.website_description
return ret
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"