[IMP] website_sale: split python files by classes

Part-of: odoo/odoo#82094
This commit is contained in:
Victor Feyens
2022-01-03 12:34:21 +00:00
parent eb6004d704
commit 313123c5fb
3 changed files with 33 additions and 28 deletions
+1
View File
@@ -19,6 +19,7 @@ from . import res_config_settings
from . import res_country
from . import res_partner
from . import sale_order
from . import sale_order_line
from . import website
from . import website_page
from . import website_snippet_filter
-28
View File
@@ -359,31 +359,3 @@ class SaleOrder(models.Model):
if not order.transaction_ids and not order.amount_total and self._context.get('send_email'):
order._send_order_confirmation_mail()
return res
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
name_short = fields.Char(compute="_compute_name_short")
linked_line_id = fields.Many2one('sale.order.line', string='Linked Order Line', domain="[('order_id', '!=', order_id)]", ondelete='cascade')
option_line_ids = fields.One2many('sale.order.line', 'linked_line_id', string='Options Linked')
def get_sale_order_line_multiline_description_sale(self, product):
description = super(SaleOrderLine, self).get_sale_order_line_multiline_description_sale(product)
if self.linked_line_id:
description += "\n" + _("Option for: %s", self.linked_line_id.product_id.display_name)
if self.option_line_ids:
description += "\n" + '\n'.join([_("Option: %s", option_line.product_id.display_name) for option_line in self.option_line_ids])
return description
@api.depends('product_id.display_name')
def _compute_name_short(self):
""" Compute a short name for this sale order line, to be used on the website where we don't have much space.
To keep it short, instead of using the first line of the description, we take the product name without the internal reference.
"""
for record in self:
record.name_short = record.product_id.with_context(display_default_code=False).display_name
def get_description_following_lines(self):
return self.name.splitlines()[1:]
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, fields, _
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
name_short = fields.Char(compute="_compute_name_short")
linked_line_id = fields.Many2one('sale.order.line', string='Linked Order Line', domain="[('order_id', '!=', order_id)]", ondelete='cascade')
option_line_ids = fields.One2many('sale.order.line', 'linked_line_id', string='Options Linked')
def get_sale_order_line_multiline_description_sale(self, product):
description = super(SaleOrderLine, self).get_sale_order_line_multiline_description_sale(product)
if self.linked_line_id:
description += "\n" + _("Option for: %s", self.linked_line_id.product_id.display_name)
if self.option_line_ids:
description += "\n" + '\n'.join([_("Option: %s", option_line.product_id.display_name) for option_line in self.option_line_ids])
return description
@api.depends('product_id.display_name')
def _compute_name_short(self):
""" Compute a short name for this sale order line, to be used on the website where we don't have much space.
To keep it short, instead of using the first line of the description, we take the product name without the internal reference.
"""
for record in self:
record.name_short = record.product_id.with_context(display_default_code=False).display_name
def get_description_following_lines(self):
return self.name.splitlines()[1:]