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

@@ -45,23 +45,42 @@ class TestChargeTaxLot(TransactionCase):
self.assertAlmostEqual(wiz.total_tax, 19.5, places=2)
self.assertAlmostEqual(wiz.total_amount, 169.5, places=2)
# ----- Task 4: lot pricing -----
# ----- Task 4: lot pricing (order-level toggle) -----
def test_lot_onchange_derives_unit_price(self):
wiz = self._make_wizard()
wiz = self._make_wizard(is_lot_order=True)
line = self.env['fp.direct.order.line'].new({
'wizard_id': wiz.id, 'quantity': 500, 'lot_total': 1000.0,
'is_lot_priced': True,
})
line._onchange_lot_pricing()
self.assertEqual(line.unit_price, 2.0)
def test_lot_line_subtotal_uses_lot_total(self):
# Even if unit_price wasn't derived (onchange didn't fire), the
# summary subtotal uses the flat lot_total for lot-priced lines.
wiz = self._make_wizard(tax_id=self.tax13.id)
def test_lot_onchange_noop_when_not_lot_order(self):
# Editing lot_total on a non-lot order must NOT touch unit_price.
wiz = self._make_wizard()
line = self.env['fp.direct.order.line'].new({
'wizard_id': wiz.id, 'quantity': 500, 'lot_total': 1000.0,
'unit_price': 7.0,
})
line._onchange_lot_pricing()
self.assertEqual(line.unit_price, 7.0)
def test_lot_order_toggle_rederives_line_prices(self):
wiz = self._make_wizard()
self.env['fp.direct.order.line'].create({
'wizard_id': wiz.id, 'quantity': 500, 'lot_total': 1000.0,
'is_lot_priced': True, 'unit_price': 0.0,
'unit_price': 0.0,
})
wiz.is_lot_order = True
wiz._onchange_is_lot_order()
self.assertEqual(wiz.line_ids.unit_price, 2.0)
def test_lot_line_subtotal_uses_lot_total(self):
# On a lot order, the summary subtotal uses the flat lot_total
# per line (not qty × unit_price), even if unit_price is 0.
wiz = self._make_wizard(tax_id=self.tax13.id, is_lot_order=True)
self.env['fp.direct.order.line'].create({
'wizard_id': wiz.id, 'quantity': 500, 'lot_total': 1000.0,
'unit_price': 0.0,
})
wiz.invalidate_recordset()
self.assertEqual(wiz.total_subtotal, 1000.0)