From 83d6ba6e0d67f421dbe2cdfe630a9900db9e4275 Mon Sep 17 00:00:00 2001 From: Demesmaeker Date: Wed, 24 Aug 2022 09:50:24 +0000 Subject: [PATCH] [FIX] sale: fallback on the product uom `_compute_discount` from subscription add dependencies that triggered the compute before the `product_uom` was set in a sale order line, once the uom is set, the `_compute_discount` will be triggered again. task-2960768 closes odoo/odoo#98780 Related: odoo/enterprise#30721 Signed-off-by: Victor Feyens (vfe) --- addons/sale/models/account_move_line.py | 2 +- addons/sale/models/sale_order_line.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/sale/models/account_move_line.py b/addons/sale/models/account_move_line.py index 27f559bbd0a..413abc9265d 100644 --- a/addons/sale/models/account_move_line.py +++ b/addons/sale/models/account_move_line.py @@ -185,7 +185,7 @@ class AccountMoveLine(models.Model): return order.pricelist_id._get_product_price( self.product_id, 1.0, - self.product_uom_id, + uom=self.product_uom_id, date=order.date_order, ) diff --git a/addons/sale/models/sale_order_line.py b/addons/sale/models/sale_order_line.py index 24ced32950c..fad44e22147 100644 --- a/addons/sale/models/sale_order_line.py +++ b/addons/sale/models/sale_order_line.py @@ -388,8 +388,8 @@ class SaleOrderLine(models.Model): line.pricelist_item_id = line.order_id.pricelist_id._get_product_rule( line.product_id, line.product_uom_qty or 1.0, - line.product_uom, - line.order_id.date_order, + uom=line.product_uom, + date=line.order_id.date_order, ) @api.depends('product_id', 'product_uom', 'product_uom_qty') @@ -451,9 +451,10 @@ class SaleOrderLine(models.Model): order_date = self.order_id.date_order or fields.Date.today() product = self.product_id.with_context(**self._get_product_price_context()) qty = self.product_uom_qty or 1.0 + uom = self.product_uom or self.product_id.uom_id price = pricelist_rule._compute_price( - product, qty, self.product_uom, order_date, self.currency_id) + product, qty, uom, order_date, currency=self.currency_id) return price