From 68c9d8e76b176e57433c82708c8fcdcf39fe1c68 Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Tue, 11 Feb 2025 13:32:57 +0100 Subject: [PATCH] Test actual quantity against None for processed quantity in Blanket Agreement Closes #13865 (grafted from 93394d850038adab243cd1f10c6f20b9732ca23a) --HG-- branch : 7.0 --- modules/purchase_blanket_agreement/purchase.py | 7 ++++--- modules/purchase_secondary_unit/purchase.py | 5 ++++- modules/sale_blanket_agreement/sale.py | 7 ++++--- modules/sale_secondary_unit/sale.py | 5 ++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/purchase_blanket_agreement/purchase.py b/modules/purchase_blanket_agreement/purchase.py index 287f9afd73..4e89bc3b6c 100644 --- a/modules/purchase_blanket_agreement/purchase.py +++ b/modules/purchase_blanket_agreement/purchase.py @@ -821,9 +821,10 @@ class Line(metaclass=PoolMeta): pool = Pool() Uom = pool.get('product.uom') if self.unit.category == line.unit.category: - return Uom.compute_qty( - self.unit, (self.actual_quantity or self.quantity), line.unit, - round=round) + quantity = ( + self.actual_quantity if self.actual_quantity is not None + else self.quantity) + return Uom.compute_qty(self.unit, quantity, line.unit, round=round) return 0 diff --git a/modules/purchase_secondary_unit/purchase.py b/modules/purchase_secondary_unit/purchase.py index 2b872823b7..2af6aea180 100644 --- a/modules/purchase_secondary_unit/purchase.py +++ b/modules/purchase_secondary_unit/purchase.py @@ -351,8 +351,11 @@ class LineBlanketAgreement(metaclass=PoolMeta): quantity = super().quantity_for_blanket_agreement(line, round=round) if (self.secondary_unit and self.secondary_unit.category == line.unit.category): + purchase_line_quantity = ( + self.actual_quantity if self.actual_quantity is not None + else self.quantity) quantity = Uom.compute_qty( - self.unit, (self.actual_quantity or self.quantity), line.unit, + self.unit, purchase_line_quantity, line.unit, factor=self.secondary_uom_factor, rate=self.secondary_uom_rate, round=round) diff --git a/modules/sale_blanket_agreement/sale.py b/modules/sale_blanket_agreement/sale.py index 2e2cd54885..679e1edafa 100644 --- a/modules/sale_blanket_agreement/sale.py +++ b/modules/sale_blanket_agreement/sale.py @@ -757,9 +757,10 @@ class Line(metaclass=PoolMeta): pool = Pool() Uom = pool.get('product.uom') if self.unit.category == line.unit.category: - return Uom.compute_qty( - self.unit, (self.actual_quantity or self.quantity), line.unit, - round=round) + quantity = ( + self.actual_quantity if self.actual_quantity is not None + else self.quantity) + return Uom.compute_qty(self.unit, quantity, line.unit, round=round) return 0 diff --git a/modules/sale_secondary_unit/sale.py b/modules/sale_secondary_unit/sale.py index 2b23e15231..b0cf864f4e 100644 --- a/modules/sale_secondary_unit/sale.py +++ b/modules/sale_secondary_unit/sale.py @@ -300,8 +300,11 @@ class LineBlanketAgreement(metaclass=PoolMeta): quantity = super().quantity_for_blanket_agreement(line, round=round) if (self.secondary_unit and self.secondary_unit.category == line.unit.category): + sale_line_quantity = ( + self.actual_quantity if self.actual_quantity is not None + else self.quantity) quantity = Uom.compute_qty( - self.unit, (self.actual_quantity or self.quantity), line.unit, + self.unit, sale_line_quantity, line.unit, factor=self.secondary_uom_factor, rate=self.secondary_uom_rate, round=round)