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):