From 3da10e34c7e2f37a2159a8f6d0aec1de67b4569d Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Feb 2023 09:36:50 +0100 Subject: [PATCH] fix method compute amound line all --- .../models/pos_order_model.py | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/pos_orderline_absolute_discount/models/pos_order_model.py b/pos_orderline_absolute_discount/models/pos_order_model.py index 07e07d034a..45a635b103 100644 --- a/pos_orderline_absolute_discount/models/pos_order_model.py +++ b/pos_orderline_absolute_discount/models/pos_order_model.py @@ -45,29 +45,30 @@ class PosOrderLine(models.Model): "price_unit", "tax_ids", "qty", "discount", "product_id", "absolute_discount" ) def _compute_amount_line_all(self): - super(PosOrderLine, self)._compute_amount_line_all() - for line in self: - fpos = line.order_id.fiscal_position_id - tax_ids_after_fiscal_position = ( - fpos.map_tax(line.tax_ids, line.product_id, line.order_id.partner_id) - if fpos - else line.tax_ids + self.ensure_one() + res = super(PosOrderLine, self)._compute_amount_line_all() + fpos = self.order_id.fiscal_position_id + tax_ids_after_fiscal_position = ( + fpos.map_tax(self.tax_ids, self.product_id, self.order_id.partner_id) + if fpos + else self.tax_ids + ) + if self.absolute_discount: + price = self.price_unit - self.absolute_discount + taxes = tax_ids_after_fiscal_position.compute_all( + price, + self.order_id.pricelist_id.currency_id, + self.qty, + product=self.product_id, + partner=self.order_id.partner_id, ) - if line.absolute_discount: - price = line.price_unit - line.absolute_discount - taxes = tax_ids_after_fiscal_position.compute_all( - price, - line.order_id.pricelist_id.currency_id, - line.qty, - product=line.product_id, - partner=line.order_id.partner_id, - ) - line.update( - { - "price_subtotal_incl": taxes["total_included"], - "price_subtotal": taxes["total_excluded"], - } - ) + res.update( + { + "price_subtotal_incl": taxes["total_included"], + "price_subtotal": taxes["total_excluded"], + } + ) + return res @api.onchange("qty", "discount", "price_unit", "tax_ids", "absolute_discount") def _onchange_qty(self):