Skip to content
Snippets Groups Projects
Commit 29b3b21a authored by Romain Derie's avatar Romain Derie
Browse files

[FIX] website_sale: website_order_line becomes computed field

Fix on sale_coupon (enterprise) https://github.com/odoo/enterprise/pull/2224 needs this change to be able to merge
SO lines when a program generates multiple discount lines on different taxes.

Closes #24971
task-1866977
task-1832967
task-1857843
parent b28f705b
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,9 @@ class SaleOrder(models.Model):
_inherit = "sale.order"
website_order_line = fields.One2many(
'sale.order.line', 'order_id',
string='Order Lines displayed on Website', readonly=True,
'sale.order.line',
compute='_compute_website_order_line',
string='Order Lines displayed on Website',
help='Order Lines to be displayed on the website. They should not be used for computation purpose.',
)
cart_quantity = fields.Integer(compute='_compute_cart_info', string='Cart Quantity')
......@@ -23,6 +24,10 @@ class SaleOrder(models.Model):
payment_tx_id = fields.Many2one('payment.transaction', string='Transaction', copy=False)
only_services = fields.Boolean(compute='_compute_cart_info', string='Only Services')
@api.one
def _compute_website_order_line(self):
self.website_order_line = self.order_line
@api.multi
@api.depends('website_order_line.product_uom_qty', 'website_order_line.product_id')
def _compute_cart_info(self):
......
......@@ -18,11 +18,11 @@ class SaleOrder(models.Model):
has_delivery = fields.Boolean(
compute='_compute_has_delivery', string='Has delivery',
help="Has an order line set for delivery", store=True)
website_order_line = fields.One2many(
'sale.order.line', 'order_id',
string='Order Lines displayed on Website', readonly=True,
domain=[('is_delivery', '=', False)],
help='Order Lines to be displayed on the website. They should not be used for computation purpose.')
@api.one
def _compute_website_order_line(self):
super(SaleOrder, self)._compute_website_order_line()
self.website_order_line = self.website_order_line.filtered(lambda l: not l.is_delivery)
@api.depends('order_line.price_unit', 'order_line.tax_id', 'order_line.discount', 'order_line.product_uom_qty')
def _compute_amount_delivery(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment