From 36b94b98af1bd5172d5ed3ff8f5672ebab054a38 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Mon, 23 Mar 2026 09:10:55 +0100 Subject: [PATCH] 23.03.26 --- modules/purchase_trade/purchase.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/purchase_trade/purchase.py b/modules/purchase_trade/purchase.py index 5a874bf..3921b7a 100755 --- a/modules/purchase_trade/purchase.py +++ b/modules/purchase_trade/purchase.py @@ -1147,11 +1147,15 @@ class Line(metaclass=PoolMeta): def get_basis_price(self): price = Decimal(0) - for pc in self.price_components: - PP = Pool().get('purchase.pricing.summary') - pp = PP.search([('price_component','=',pc.id),('line','=',self.id)]) - if pp: - price += pp[0].price * (pc.ratio / 100) + if self.terms: + for t in self.terms: + price += t.manual_price + else: + for pc in self.price_components: + PP = Pool().get('purchase.pricing.summary') + pp = PP.search([('price_component','=',pc.id),('line','=',self.id)]) + if pp: + price += pp[0].price * (pc.ratio / 100) return round(price,4) def get_price(self,lot_premium=0): @@ -1170,8 +1174,9 @@ class Line(metaclass=PoolMeta): Date = Pool().get('ir.date') logger.info("ONCHANGEUNITPRICE:%s",self.unit_price) if self.price_type == 'basis' and self.lots: #self.price_pricing and self.price_components and - logger.info("ONCHANGEUNITPRICE_IN:%s",self.get_basis_price()) - return self.get_basis_price() + price = self.get_basis_price() + logger.info("ONCHANGEUNITPRICE_IN:%s",price) + return price if self.enable_linked_currency and self.linked_price and self.linked_currency and self.price_type == 'priced': return self.get_price_linked_currency() if self.price_type == 'efp': @@ -1345,6 +1350,8 @@ class Line(metaclass=PoolMeta): price = Decimal(cp.get_last_price()) logger.info("PRICE:%s",price) t.manual_price = round(t.payable_rule.compute_payable_quantity(grade) * price / Decimal(100) - t.penalty_rules.compute_penalty(grade),2) + t.currency = t.component.currency + t.unit = self.unit Concentrate.save([t]) if self.price_components: