2
0
account-financial-tools/account_journal_general_sequence/models/account_journal.py
Jairo Llopis 1a1d816c7b
[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
2022-12-23 10:22:43 +00:00

40 lines
1.3 KiB
Python

# Copyright 2022 Moduon
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import logging
from odoo import _, fields, models
_logger = logging.getLogger(__name__)
class AccountJournal(models.Model):
_inherit = "account.journal"
entry_number_sequence_id = fields.Many2one(
comodel_name="ir.sequence",
string="Account entry number sequence",
default=lambda self: self._default_entry_number_sequence(),
copy=False,
help="Sequence used for account entry numbering.",
)
def _default_entry_number_sequence(self):
"""Get the default sequence for all journals."""
result = self.env["ir.sequence"].search(
[("code", "=", "account_journal_general_sequence.default")]
)
if result:
return result
_logger.info("Creating default sequence for account move numbers")
result = self.env["ir.sequence"].create(
{
"name": _("Account entry default numbering"),
"code": "account_journal_general_sequence.default",
"implementation": "no_gap",
"prefix": "%(range_year)s/",
"padding": 10,
"use_date_range": True,
}
)
return result