mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[ADD] account_journal_general_sequence: account move entry sequence
Under some legislations, account moves must follow a single sequence. Since Odoo removed this sequence number in recent versions, this information was lost. With this module, you can force your account moves to follow a separate sequence. The sequence is automatic when a move is posted. Includes a wizard to reorder those numbers in the sequence. @moduon MT-676
This commit is contained in:
46
account_journal_general_sequence/tests/test_numbering.py
Normal file
46
account_journal_general_sequence/tests/test_numbering.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright 2022 Moduon
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo.tests.common import Form, tagged
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
from odoo.addons.account.tests.common import TestAccountReconciliationCommon
|
||||
|
||||
|
||||
@freeze_time("2022-05-11", tick=True)
|
||||
@tagged("post_install", "-at_install")
|
||||
class RenumberCase(TestAccountReconciliationCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
def test_invoice_gets_entry_number(self):
|
||||
# Draft invoice without entry number
|
||||
invoice = self._create_invoice()
|
||||
self.assertFalse(invoice.entry_number)
|
||||
# Gets one once posted
|
||||
invoice.action_post()
|
||||
self.assertTrue(invoice.entry_number.startswith("2022/"))
|
||||
# Lost number when canceled
|
||||
with mute_logger(
|
||||
"odoo.addons.account_journal_general_sequence.models.account_move"
|
||||
):
|
||||
invoice.button_cancel()
|
||||
self.assertFalse(invoice.entry_number)
|
||||
|
||||
def test_renumber(self):
|
||||
# Post invoices in wrong order
|
||||
new_invoice = self._create_invoice(
|
||||
date_invoice="2022-05-10", auto_validate=True
|
||||
)
|
||||
old_invoice = self._create_invoice(
|
||||
date_invoice="2022-04-30", auto_validate=True
|
||||
)
|
||||
self.assertLess(new_invoice.entry_number, old_invoice.entry_number)
|
||||
# Fix entry number order with wizard; default values are OK
|
||||
wiz_f = Form(self.env["account.move.renumber.wizard"])
|
||||
self.assertEqual(len(wiz_f.available_sequence_ids), 1)
|
||||
wiz = wiz_f.save()
|
||||
wiz.action_renumber()
|
||||
self.assertGreater(new_invoice.entry_number, old_invoice.entry_number)
|
||||
Reference in New Issue
Block a user