From d4f2629b0876b08a88559266562801ce86943f30 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 20 Jan 2023 12:11:00 +0100 Subject: [PATCH] [FIX] account_move_name_sequence: With the "account_move_name_sequence" module the "_get_last_sequence" method does not have to propagate the with_prefix parameter. The sequence_prefix parameter will not be completed and will give error as it is False in this line of code. https://github.com/OCA/OCB/blob/15.0/addons/account/models/sequence_mixin.py#L164 --- .../models/account_move.py | 3 ++ .../tests/test_account_move_name_seq.py | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/account_move_name_sequence/models/account_move.py b/account_move_name_sequence/models/account_move.py index d843c762f..37782771c 100644 --- a/account_move_name_sequence/models/account_move.py +++ b/account_move_name_sequence/models/account_move.py @@ -68,3 +68,6 @@ class AccountMove(models.Model): def _post(self, soft=True): self.flush() return super()._post(soft=soft) + + def _get_last_sequence(self, relaxed=False, with_prefix=None, lock=True): + return super()._get_last_sequence(relaxed, None, lock) diff --git a/account_move_name_sequence/tests/test_account_move_name_seq.py b/account_move_name_sequence/tests/test_account_move_name_seq.py index 207ca6139..faa11b988 100644 --- a/account_move_name_sequence/tests/test_account_move_name_seq.py +++ b/account_move_name_sequence/tests/test_account_move_name_seq.py @@ -189,3 +189,35 @@ class TestAccountMoveNameSequence(TransactionCase): error_msg = "You cannot delete this entry, as it has already consumed a" with self.assertRaisesRegex(UserError, error_msg): invoice.unlink() + + def test_remove_invoice_error_secuence_standard(self): + implementation = {"implementation": "standard"} + self.purchase_journal.sequence_id.write(implementation) + self.purchase_journal.refund_sequence_id.write(implementation) + in_refund_invoice = self.env["account.move"].create( + { + "journal_id": self.purchase_journal.id, + "invoice_date": self.date, + "partner_id": self.env.ref("base.res_partner_3").id, + "move_type": "in_refund", + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.account1.id, + "price_unit": 42.0, + "quantity": 12, + }, + ) + ], + } + ) + self.assertEqual(in_refund_invoice.name, "/") + in_refund_invoice.action_post() + error_msg = "You cannot delete an item linked to a posted entry." + with self.assertRaisesRegex(UserError, error_msg): + in_refund_invoice.unlink() + in_refund_invoice.button_draft() + in_refund_invoice.button_cancel() + self.assertTrue(in_refund_invoice.unlink())