From d9cf6c9a49b8d7d3bb560c12c12bb167d2ccd1b7 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 3 Mar 2026 12:00:35 +0100 Subject: [PATCH] 03.03.26 --- modules/purchase_trade/party.py | 20 ++++++++++++++++++- modules/purchase_trade/stock.py | 13 +++++++----- .../view/party_exec_place_tree.xml | 4 +++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/modules/purchase_trade/party.py b/modules/purchase_trade/party.py index 2fbf46f..a8063e5 100755 --- a/modules/purchase_trade/party.py +++ b/modules/purchase_trade/party.py @@ -5,6 +5,7 @@ from trytond.modules.purchase_trade.purchase import (TRIGGERS) from trytond.transaction import Transaction from decimal import getcontext, Decimal, ROUND_HALF_UP from sql import Table +from trytond.pyson import Bool, Eval, Id, If class PartyExecution(ModelSQL,ModelView): "Party Execution" @@ -36,6 +37,23 @@ class PartyExecutionPlace(ModelSQL,ModelView): pes = fields.Many2One('party.execution.sla',"Sla") location = fields.Many2One('stock.location',"Location") cost = fields.Numeric("Cost",digits=(16,4)) + mode = fields.Selection([ + ('lumpsum', 'Lump sum'), + ('perqt', 'Per qt'), + ('pprice', '% price'), + ('rate', '% rate'), + ('pcost', '% cost price'), + ('ppack', 'Per packing'), + ], 'Mode', required=True) + currency = fields.Many2One('currency.currency',"Currency") + unit = fields.Many2One('product.uom',"Unit",domain=[ + If(Eval('mode') == 'ppack', + ('category', '=', 8), + ()), + ], + states={ + 'readonly': Eval('mode') != 'ppack', + }) currency_unit = fields.Selection('get_currency_unit',string="Curr/Unit") @staticmethod @@ -74,7 +92,7 @@ class Party(metaclass=PoolMeta): SlaPlace = Pool().get('party.execution.place') sp = SlaPlace.search([('pes','=', sla.id),('location','=',location)]) if sp: - return round(((sp[0].cost / Decimal(100)) * Decimal(2.2046)),4) + return round(((sp[0].cost / Decimal(100)) * Decimal(2.2046)),4),sp[0].mode,sp[0].currency,sp[0].unit def get_alf(self): if self.name == 'CARGO CONTROL': diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py index f918411..37be6a7 100755 --- a/modules/purchase_trade/stock.py +++ b/modules/purchase_trade/stock.py @@ -475,11 +475,14 @@ class ShipmentIn(metaclass=PoolMeta): fee.supplier = controller fee.type = 'budgeted' fee.p_r = 'pay' - fee.mode = 'perqt' - fee.currency = 1 - fee.product = Product.get_by_name('Reweighing') - fee.price = controller.get_sla_cost(self.to_location) - Fee.save([fee]) + price,mode,curr,unit = controller.get_sla_cost(self.to_location) + if price and mode and curr and unit: + fee.mode = mode + fee.currency = curr + fee.unit = unit + fee.product = Product.get_by_name('Reweighing') + fee.price = price + Fee.save([fee]) def get_controller(self): ControllerCategory = Pool().get('party.category') diff --git a/modules/purchase_trade/view/party_exec_place_tree.xml b/modules/purchase_trade/view/party_exec_place_tree.xml index 399f3cc..cdb7b99 100644 --- a/modules/purchase_trade/view/party_exec_place_tree.xml +++ b/modules/purchase_trade/view/party_exec_place_tree.xml @@ -1,5 +1,7 @@ + - + + \ No newline at end of file