fix(plating): order-level Lot Order toggle replaces per-line lot checkbox

Express order entry now has a single "Lot Order" toggle on the header
instead of a per-line "Lot" checkbox. When on, every line shows Lot
Total and prices as a flat lot (unit price derived = lot total / qty,
qty preserved for production); when off, the Lot Total column is hidden
and lines price per unit as usual. Keeps the order summary clean for the
common per-unit case.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-29 22:44:07 -04:00
parent 2bd0672b52
commit 028814b292
5 changed files with 65 additions and 27 deletions

View File

@@ -238,20 +238,17 @@ 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',
help='Flat total for the whole line quantity when the order is a '
'lot order. Unit price is derived = lot total / quantity; '
'the quantity is preserved for production.',
)
@api.onchange('is_lot_priced', 'lot_total', 'quantity')
@api.onchange('lot_total', 'quantity')
def _onchange_lot_pricing(self):
for line in self:
if line.is_lot_priced and line.quantity:
if line.wizard_id.is_lot_order and line.quantity:
line.unit_price = (line.lot_total or 0.0) / line.quantity
line_subtotal = fields.Monetary(
string='Subtotal',

View File

@@ -336,6 +336,22 @@ class FpDirectOrderWizard(models.Model):
if rec.charge_type_id and not rec.charge_amount:
rec.charge_amount = rec.charge_type_id.default_amount
is_lot_order = fields.Boolean(
string='Lot Order',
help='Price the order as flat lots instead of per unit. When on, '
'each line takes a Lot Total and the unit price is derived = '
'lot total / quantity; the quantity is preserved for '
'production. When off, lines price per unit as usual.',
)
@api.onchange('is_lot_order')
def _onchange_is_lot_order(self):
for rec in self:
if rec.is_lot_order:
for line in rec.line_ids:
if line.quantity:
line.unit_price = (line.lot_total or 0.0) / line.quantity
# ---- PO status pill (computed, display-only) ----
po_status = fields.Selection(
[('received', 'Received'),
@@ -403,8 +419,8 @@ class FpDirectOrderWizard(models.Model):
@api.depends(
'line_ids.quantity',
'line_ids.unit_price',
'line_ids.is_lot_priced',
'line_ids.lot_total',
'is_lot_order',
'charge_amount',
'tooling_charge',
'tax_id',
@@ -420,11 +436,13 @@ class FpDirectOrderWizard(models.Model):
at action_create_order time (so it carries into the invoice).
"""
for rec in self:
subtotal = sum(
(l.lot_total or 0.0) if l.is_lot_priced
else (l.quantity or 0) * (l.unit_price or 0.0)
for l in rec.line_ids
)
if rec.is_lot_order:
subtotal = sum(l.lot_total or 0.0 for l in rec.line_ids)
else:
subtotal = sum(
(l.quantity or 0) * (l.unit_price or 0.0)
for l in rec.line_ids
)
charge = rec.charge_amount or rec.tooling_charge or 0.0
tax_total = 0.0
if rec.tax_id and (subtotal + charge):
@@ -858,7 +876,7 @@ class FpDirectOrderWizard(models.Model):
'product_uom_qty': line.quantity,
'price_unit': (
(line.lot_total / line.quantity)
if line.is_lot_priced and line.quantity
if self.is_lot_order and line.quantity
else (line.unit_price or 0.0)
),
'x_fc_part_catalog_id': part.id,
@@ -904,7 +922,7 @@ class FpDirectOrderWizard(models.Model):
# NB. Odoo 19 renamed the SO line field to tax_ids.
'tax_ids': ([(6, 0, self.tax_id.ids)]
if self.tax_id else False),
'x_fc_is_lot_priced': line.is_lot_priced,
'x_fc_is_lot_priced': self.is_lot_order,
'x_fc_lot_total': line.lot_total or 0.0,
}))