From e5e4ca6554f5781a620f357eba562ed566222aeb Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Tue, 10 May 2022 16:13:47 +0000 Subject: [PATCH] [MOV] sale_quotation_builder: split sale_order_template.py Part-of: odoo/odoo#91222 --- .../sale_quotation_builder/models/__init__.py | 2 + .../models/sale_order_template.py | 56 +------------------ .../models/sale_order_template_line.py | 32 +++++++++++ .../models/sale_order_template_option.py | 30 ++++++++++ 4 files changed, 66 insertions(+), 54 deletions(-) create mode 100644 addons/sale_quotation_builder/models/sale_order_template_line.py create mode 100644 addons/sale_quotation_builder/models/sale_order_template_option.py diff --git a/addons/sale_quotation_builder/models/__init__.py b/addons/sale_quotation_builder/models/__init__.py index 13669f84f0f..af602f5aa92 100644 --- a/addons/sale_quotation_builder/models/__init__.py +++ b/addons/sale_quotation_builder/models/__init__.py @@ -7,3 +7,5 @@ from . import sale_order from . import sale_order_line from . import sale_order_option from . import sale_order_template +from . import sale_order_template_line +from . import sale_order_template_option diff --git a/addons/sale_quotation_builder/models/sale_order_template.py b/addons/sale_quotation_builder/models/sale_order_template.py index 0ead70fc741..a5e862b273e 100644 --- a/addons/sale_quotation_builder/models/sale_order_template.py +++ b/addons/sale_quotation_builder/models/sale_order_template.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import fields, models from odoo.tools.translate import html_translate class SaleOrderTemplate(models.Model): - _inherit = "sale.order.template" + _inherit = 'sale.order.template' website_description = fields.Html( string="Website Description", @@ -20,55 +20,3 @@ class SaleOrderTemplate(models.Model): 'target': 'self', 'url': '/sale_quotation_builder/template/%d' % self.id } - - -class SaleOrderTemplateLine(models.Model): - _inherit = "sale.order.template.line" - - # FIXME ANVFE why are the sanitize_* attributes different between this field - # and the one on option lines, doesn't make any sense ??? - website_description = fields.Html( - string="Website Description", - compute='_compute_website_description', - store=True, readonly=False, - translate=html_translate, - sanitize_form=False) - - @api.depends('product_id') - def _compute_website_description(self): - for line in self: - if not line.product_id: - continue - line.website_description = line.product_id.quotation_description - - #=== BUSINESS METHODS ===# - - def _prepare_order_line_values(self): - res = super()._prepare_order_line_values() - res['website_description'] = self.website_description - return res - - -class SaleOrderTemplateOption(models.Model): - _inherit = "sale.order.template.option" - - website_description = fields.Html( - string="Website Description", - compute="_compute_website_description", - store=True, readonly=False, - translate=html_translate, - sanitize_attributes=False) - - @api.depends('product_id') - def _compute_website_description(self): - for option in self: - if not option.product_id: - continue - option.website_description = option.product_id.quotation_description - - #=== BUSINESS METHODS ===# - - def _prepare_option_line_values(self): - res = super()._prepare_option_line_values() - res['website_description'] = self.website_description - return res diff --git a/addons/sale_quotation_builder/models/sale_order_template_line.py b/addons/sale_quotation_builder/models/sale_order_template_line.py new file mode 100644 index 00000000000..a20db68147e --- /dev/null +++ b/addons/sale_quotation_builder/models/sale_order_template_line.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models +from odoo.tools.translate import html_translate + + +class SaleOrderTemplateLine(models.Model): + _inherit = 'sale.order.template.line' + + # FIXME ANVFE why are the sanitize_* attributes different between this field + # and the one on option lines, doesn't make any sense ??? + website_description = fields.Html( + string="Website Description", + compute='_compute_website_description', + store=True, readonly=False, + translate=html_translate, + sanitize_form=False) + + @api.depends('product_id') + def _compute_website_description(self): + for line in self: + if not line.product_id: + continue + line.website_description = line.product_id.quotation_description + + #=== BUSINESS METHODS ===# + + def _prepare_order_line_values(self): + res = super()._prepare_order_line_values() + res['website_description'] = self.website_description + return res diff --git a/addons/sale_quotation_builder/models/sale_order_template_option.py b/addons/sale_quotation_builder/models/sale_order_template_option.py new file mode 100644 index 00000000000..308a1e1581b --- /dev/null +++ b/addons/sale_quotation_builder/models/sale_order_template_option.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models +from odoo.tools.translate import html_translate + + +class SaleOrderTemplateOption(models.Model): + _inherit = 'sale.order.template.option' + + website_description = fields.Html( + string="Website Description", + compute='_compute_website_description', + store=True, readonly=False, + translate=html_translate, + sanitize_attributes=False) + + @api.depends('product_id') + def _compute_website_description(self): + for option in self: + if not option.product_id: + continue + option.website_description = option.product_id.quotation_description + + #=== BUSINESS METHODS ===# + + def _prepare_option_line_values(self): + res = super()._prepare_option_line_values() + res['website_description'] = self.website_description + return res