[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

This commit is contained in:
Rodrigo
2023-01-20 12:11:00 +01:00
parent cbd6318ee2
commit d4f2629b08
2 changed files with 35 additions and 0 deletions

View File

@@ -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)

View File

@@ -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())