diff --git a/modules/purchase_trade/duplicate.py b/modules/purchase_trade/duplicate.py index 26ad0ba..f62e9f1 100644 --- a/modules/purchase_trade/duplicate.py +++ b/modules/purchase_trade/duplicate.py @@ -151,6 +151,8 @@ class TradeCustomDuplicate(Wizard): line.quantity_theorical = options.quantity line.unit_price = options.unit_price line.price_type = options.price_type + if hasattr(line, 'finished'): + line.finished = False if hasattr(line, 'currency'): line.currency = options.currency if options.clear_fees and hasattr(line, 'fees'): diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index 70953ca..7c7eccb 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -6054,6 +6054,35 @@ class PurchaseTradeTestCase(ModuleTestCase): self.assertIsNone( ContractFactory._get_shipment_origin(ContractsStartMock())) + def test_custom_duplicate_resets_finished_line(self): + 'custom duplicate keeps duplicated lots visible in lots management' + line = Mock( + product=Mock(), + quantity=None, + quantity_theorical=None, + unit_price=None, + price_type=None, + finished=True, + fees=[], + price_components=[], + ) + record = Mock(lines=[line]) + options = Mock( + quantity=Decimal('100'), + unit_price=Decimal('25'), + price_type='priced', + currency=Mock(), + clear_fees=False, + clear_pricing_components=False, + ) + line.id = 1 + + duplicate_module.TradeCustomDuplicate._apply_line_options( + record, options) + + self.assertFalse(line.finished) + line.save.assert_called_once() + def test_custom_duplicate_creates_purchase_open_virtual_lot(self): 'custom duplicate creates the purchase opening lot.qt explicitly' saved_lots = []