feat(configurator): per-line lot pricing (derive unit price, keep qty)

This commit is contained in:
gsinghpal
2026-05-29 21:38:49 -04:00
parent f8929eb686
commit a2ac804238
2 changed files with 25 additions and 0 deletions

View File

@@ -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',