feat(configurator): per-line lot pricing (derive unit price, keep qty)
This commit is contained in:
@@ -238,6 +238,21 @@ class FpDirectOrderLine(models.Model):
|
||||
string='Unit Price',
|
||||
currency_field='currency_id',
|
||||
)
|
||||
is_lot_priced = fields.Boolean(
|
||||
string='Lot Price',
|
||||
help='Price the whole quantity as a flat lot total instead of '
|
||||
'per unit. Unit price is derived = lot total / quantity; '
|
||||
'the quantity is preserved for production.',
|
||||
)
|
||||
lot_total = fields.Monetary(
|
||||
string='Lot Total', currency_field='currency_id',
|
||||
)
|
||||
|
||||
@api.onchange('is_lot_priced', 'lot_total', 'quantity')
|
||||
def _onchange_lot_pricing(self):
|
||||
for line in self:
|
||||
if line.is_lot_priced and line.quantity:
|
||||
line.unit_price = (line.lot_total or 0.0) / line.quantity
|
||||
line_subtotal = fields.Monetary(
|
||||
string='Subtotal',
|
||||
currency_field='currency_id',
|
||||
|
||||
Reference in New Issue
Block a user