2
0

Merge PR #1576 into 16.0

Signed-off-by yajo
This commit is contained in:
OCA-git-bot 2023-02-01 09:06:08 +00:00
commit e97787edba
2 changed files with 9 additions and 4 deletions

View File

@ -39,6 +39,9 @@ class RenumberCase(TestAccountReconciliationCommon):
@users("test_manager") @users("test_manager")
def test_renumber(self): def test_renumber(self):
# Post invoices in wrong order # Post invoices in wrong order
next_year_invoice = self._create_invoice(
date_invoice="2023-12-31", auto_validate=True
)
new_invoice = self._create_invoice( new_invoice = self._create_invoice(
date_invoice="2022-05-10", auto_validate=True date_invoice="2022-05-10", auto_validate=True
) )
@ -59,10 +62,12 @@ class RenumberCase(TestAccountReconciliationCommon):
self.assertGreater(opening_invoice.entry_number, new_invoice.entry_number) self.assertGreater(opening_invoice.entry_number, new_invoice.entry_number)
# Renumber again, starting from zero # Renumber again, starting from zero
wiz_f = Form(self.env["account.move.renumber.wizard"]) wiz_f = Form(self.env["account.move.renumber.wizard"])
wiz_f.starting_number = 0
wiz = wiz_f.save() wiz = wiz_f.save()
wiz.action_renumber() wiz.action_renumber()
self.assertEqual(opening_invoice.entry_number, "2022/0000000000") self.assertEqual(opening_invoice.entry_number, "2022/0000000001")
self.assertEqual(old_invoice.entry_number, "2022/0000000002")
self.assertEqual(new_invoice.entry_number, "2022/0000000003")
self.assertEqual(next_year_invoice.entry_number, "2023/0000000001")
@users("test_invoicer") @users("test_invoicer")
def test_install_no_entry_number(self): def test_install_no_entry_number(self):

View File

@ -72,9 +72,9 @@ class AccountMoveRenumberWizard(models.TransientModel):
("sequence_id", "=", self.sequence_id.id), ("sequence_id", "=", self.sequence_id.id),
] ]
) )
future_ranges.unlink() # Safe `sudo` calls; wizard only available for accounting managers
future_ranges.sudo().unlink()
current_range = self.sequence_id._get_current_sequence(self.starting_date) current_range = self.sequence_id._get_current_sequence(self.starting_date)
# Safe `sudo`; wizard only available for accounting managers
current_range.sudo().number_next = self.starting_number current_range.sudo().number_next = self.starting_number
self.sequence_id.sudo().number_next = self.starting_number self.sequence_id.sudo().number_next = self.starting_number
# Renumber the moves # Renumber the moves