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 +