From 74d1465470f70f5a7beddce0ce1757182cc5868d Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Sun, 7 Jun 2026 21:43:37 +0200 Subject: [PATCH] Pricing form --- modules/purchase_trade/pricing.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/purchase_trade/pricing.py b/modules/purchase_trade/pricing.py index 80be547..7149590 100755 --- a/modules/purchase_trade/pricing.py +++ b/modules/purchase_trade/pricing.py @@ -995,9 +995,10 @@ class Pricing(ModelSQL,ModelView): 'pricing.component', "Component", domain=[('id', 'in', Eval('available_components', []))], depends=['available_components'])#, ondelete='CASCADE') - available_components = fields.Function( - fields.One2Many('pricing.component', '', "Available Components"), - 'on_change_with_available_components') + available_components = fields.Function( + fields.One2Many('pricing.component', '', "Available Components"), + 'on_change_with_available_components', + setter='set_available_components') quantity = fields.Numeric("Qt",digits='unit') settl_price = fields.Numeric("Settl. price",digits='unit') fixed_qt = fields.Numeric("Fixed qt",digits='unit', readonly=True) @@ -1036,15 +1037,19 @@ class Pricing(ModelSQL,ModelView): return Decimal(0) @fields.depends('line', 'sale_line') - def on_change_with_available_components(self, name=None): - Component = Pool().get('pricing.component') - line = getattr(self, 'line', None) - if line: - return Component.search([('line', '=', line)]) + def on_change_with_available_components(self, name=None): + Component = Pool().get('pricing.component') + line = getattr(self, 'line', None) + if line: + return Component.search([('line', '=', line)]) sale_line = getattr(self, 'sale_line', None) if sale_line: - return Component.search([('sale_line', '=', sale_line)]) - return [] + return Component.search([('sale_line', '=', sale_line)]) + return [] + + @classmethod + def set_available_components(cls, records, name, value): + pass @staticmethod def _weighted_average_price(fixed_qt, fixed_price, unfixed_qt, unfixed_price):