Merge PR #1566 into 15.0

Signed-off-by moylop260
This commit is contained in:
OCA-git-bot
2023-01-24 19:50:49 +00:00
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())