From 028814b292604d9230ac15a7e0aff9df9bcc66f3 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Fri, 29 May 2026 22:44:07 -0400 Subject: [PATCH] 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 --- .../__manifest__.py | 2 +- .../tests/test_charge_tax_lot.py | 35 ++++++++++++++----- .../views/fp_express_order_views.xml | 8 +++-- .../wizard/fp_direct_order_line.py | 13 +++---- .../wizard/fp_direct_order_wizard.py | 34 +++++++++++++----- 5 files changed, 65 insertions(+), 27 deletions(-) diff --git a/fusion_plating/fusion_plating_configurator/__manifest__.py b/fusion_plating/fusion_plating_configurator/__manifest__.py index 81de69aa..c6643e23 100644 --- a/fusion_plating/fusion_plating_configurator/__manifest__.py +++ b/fusion_plating/fusion_plating_configurator/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Fusion Plating — Configurator', - 'version': '19.0.23.0.0', + 'version': '19.0.23.1.0', 'category': 'Manufacturing/Plating', 'summary': 'Quotation configurator with part catalog, coating configs, and formula-based pricing engine.', 'description': """ diff --git a/fusion_plating/fusion_plating_configurator/tests/test_charge_tax_lot.py b/fusion_plating/fusion_plating_configurator/tests/test_charge_tax_lot.py index 26604f8d..569220dc 100644 --- a/fusion_plating/fusion_plating_configurator/tests/test_charge_tax_lot.py +++ b/fusion_plating/fusion_plating_configurator/tests/test_charge_tax_lot.py @@ -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) diff --git a/fusion_plating/fusion_plating_configurator/views/fp_express_order_views.xml b/fusion_plating/fusion_plating_configurator/views/fp_express_order_views.xml index 634c40f2..716b9e16 100644 --- a/fusion_plating/fusion_plating_configurator/views/fp_express_order_views.xml +++ b/fusion_plating/fusion_plating_configurator/views/fp_express_order_views.xml @@ -233,6 +233,10 @@ OPEN open the part record +
+ + Lot Order — price each line as a flat lot total (qty preserved for production) +