Pricing form

This commit is contained in:
2026-06-07 21:43:37 +02:00
parent 1abfbbbc3d
commit 74d1465470

View File

@@ -995,9 +995,10 @@ class Pricing(ModelSQL,ModelView):
'pricing.component', "Component", 'pricing.component', "Component",
domain=[('id', 'in', Eval('available_components', []))], domain=[('id', 'in', Eval('available_components', []))],
depends=['available_components'])#, ondelete='CASCADE') depends=['available_components'])#, ondelete='CASCADE')
available_components = fields.Function( available_components = fields.Function(
fields.One2Many('pricing.component', '', "Available Components"), fields.One2Many('pricing.component', '', "Available Components"),
'on_change_with_available_components') 'on_change_with_available_components',
setter='set_available_components')
quantity = fields.Numeric("Qt",digits='unit') quantity = fields.Numeric("Qt",digits='unit')
settl_price = fields.Numeric("Settl. price",digits='unit') settl_price = fields.Numeric("Settl. price",digits='unit')
fixed_qt = fields.Numeric("Fixed qt",digits='unit', readonly=True) fixed_qt = fields.Numeric("Fixed qt",digits='unit', readonly=True)
@@ -1036,15 +1037,19 @@ class Pricing(ModelSQL,ModelView):
return Decimal(0) return Decimal(0)
@fields.depends('line', 'sale_line') @fields.depends('line', 'sale_line')
def on_change_with_available_components(self, name=None): def on_change_with_available_components(self, name=None):
Component = Pool().get('pricing.component') Component = Pool().get('pricing.component')
line = getattr(self, 'line', None) line = getattr(self, 'line', None)
if line: if line:
return Component.search([('line', '=', line)]) return Component.search([('line', '=', line)])
sale_line = getattr(self, 'sale_line', None) sale_line = getattr(self, 'sale_line', None)
if sale_line: if sale_line:
return Component.search([('sale_line', '=', sale_line)]) return Component.search([('sale_line', '=', sale_line)])
return [] return []
@classmethod
def set_available_components(cls, records, name, value):
pass
@staticmethod @staticmethod
def _weighted_average_price(fixed_qt, fixed_price, unfixed_qt, unfixed_price): def _weighted_average_price(fixed_qt, fixed_price, unfixed_qt, unfixed_price):