2
0

[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:
Jairo Llopis 2022-05-23 10:23:58 +01:00
parent 1782a12048
commit 1a1d816c7b
No known key found for this signature in database
GPG Key ID: E47E3BE44B940490
24 changed files with 1431 additions and 0 deletions

View File

@ -0,0 +1,121 @@
====================================
General sequence in account journals
====================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/14.0/account_journal_general_sequence
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_journal_general_sequence
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module extends the functionality of account to support sequenced entry
numbers and to allow you to renumber them if needed, on demand.
It adds a new field called *Entry number*. This is independent from the *Number*
that Odoo adds by default, and has different purpose.
**Table of contents**
.. contents::
:local:
Configuration
=============
To configure journal sequences:
#. Have full accounting permissions.
#. Go to *Invoicing > Configuration > Accounting > Journals*.
#. Select or create the journal you want to configure.
#. Use *Account entry number sequence* to configure a sequence.
Note that:
* Various journals can share the same sequence.
* All journals get a shared default sequence, per company.
* Entry numbers must be unique per company. So, if you use different sequences
per journal, make sure they don't produce colliding results.
Usage
=====
To see journal entry numbers:
#. Go to *Invoicing > Accounting > Miscellaneous > Journal Entries*.
#. Notice the new field *Entry Number*. Only posted moves get an entry number.
Note that:
* You can use that new field in quick searches.
* You can see it also in *Invoicing > Accounting > Miscellaneous > Journal Items*.
To renumber journal entries:
#. Have full accounting permissions.
#. Have *Accounting / Invoicing / Billing Administrator* permissions.
#. Go to *Invoicing > Accounting > Actions > Renumber journal entries*.
#. Configure those parameters.
#. Click on *Renumber*.
Note that:
* You will only be able to select sequences related to journals.
* A sequence usually affects various journals, if not all.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_general_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Moduon
Contributors
~~~~~~~~~~~~
* Jairo Llopis (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_journal_general_sequence>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1,2 @@
from . import models
from . import wizards

View File

@ -0,0 +1,22 @@
# Copyright 2022 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "General sequence in account journals",
"summary": "Add configurable sequence to account moves, per journal",
"version": "14.0.1.0.0",
"category": "Accounting/Accounting",
"website": "https://github.com/OCA/account-financial-tools",
"author": "Moduon, Odoo Community Association (OCA)",
"license": "LGPL-3",
"external_dependencies": {"python": ["freezegun"]},
"depends": [
"account",
],
"data": [
"security/ir.model.access.csv",
"views/account_journal.xml",
"views/account_move_line.xml",
"views/account_move.xml",
"wizards/account_move_renumber_wizard_views.xml",
],
}

View File

@ -0,0 +1,188 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_journal_general_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-05-27 08:32+0000\n"
"PO-Revision-Date: 2022-05-27 08:32+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_journal_general_sequence
#: code:addons/account_journal_general_sequence/models/account_journal.py:0
#, python-format
msgid "Account entry default numbering"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal__entry_number_sequence_id
msgid "Account entry number sequence"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_move_renumber_wizard
msgid "Account move entry renumbering wizard"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_bank_statement_line__entry_number
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move__entry_number
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_line__entry_number
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_payment__entry_number
msgid "Automatic numbering, based on journal configuration."
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__available_sequence_ids
msgid "Available sequences"
msgstr ""
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid "Cancel"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__create_uid
msgid "Created by"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__create_date
msgid "Created on"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal__display_name
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move__display_name
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__display_name
msgid "Display Name"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_bank_statement_line__entry_number
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move__entry_number
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line__entry_number
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_payment__entry_number
msgid "Entry Number"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.constraint,message:account_journal_general_sequence.constraint_account_move_entry_number_unique
msgid "Entry number must be unique per company."
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal__id
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move__id
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line__id
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__id
msgid "ID"
msgstr ""
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid ""
"If you have already filed and legalized your journals with the competent "
"authority, this action could change it. Continue?"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_journal
msgid "Journal"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_move
msgid "Journal Entry"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_move_line
msgid "Journal Item"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal____last_update
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move____last_update
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard____last_update
msgid "Last Modified on"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__write_uid
msgid "Last Updated by"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__write_date
msgid "Last Updated on"
msgstr ""
#. module: account_journal_general_sequence
#: code:addons/account_journal_general_sequence/wizards/account_move_renumber_wizard.py:0
#, python-format
msgid "No account moves found."
msgstr ""
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid "Renumber"
msgstr ""
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid "Renumber account entry numbers"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_renumber_wizard__starting_date
msgid "Renumber account moves starting this day."
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.actions.act_window,name:account_journal_general_sequence.account_move_renumber_wizard_action
#: model:ir.ui.menu,name:account_journal_general_sequence.account_move_renumber_wizard_menu
msgid "Renumber journal entries"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_renumber_wizard__starting_number
msgid "Reset sequence to this number before starting."
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__sequence_id
msgid "Sequence"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_renumber_wizard__sequence_id
msgid ""
"Sequence to use for renumbering. Affects all journals that use this "
"sequence."
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_journal__entry_number_sequence_id
msgid "Sequence used for account entry numbering."
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__starting_date
msgid "Starting Date"
msgstr ""
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__starting_number
msgid "Starting Number"
msgstr ""

View File

@ -0,0 +1,193 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_numbered
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-05-27 08:32+0000\n"
"PO-Revision-Date: 2022-05-27 09:34+0100\n"
"Last-Translator: Jairo Llopis <jairo@moduon.team>\n"
"Language-Team: \n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"
#. module: account_journal_general_sequence
#: code:addons/account_journal_general_sequence/models/account_journal.py:0
#, python-format
msgid "Account entry default numbering"
msgstr "Numeración por defecto de asientos contables"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal__entry_number_sequence_id
msgid "Account entry number sequence"
msgstr "Secuencia para numerar los asientos"
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_move_renumber_wizard
msgid "Account move entry renumbering wizard"
msgstr "Asistente para renumerar asientos contables"
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_bank_statement_line__entry_number
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move__entry_number
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_line__entry_number
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_payment__entry_number
msgid "Automatic numbering, based on journal configuration."
msgstr "Numeración automática, basada en la configuración por diario."
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__available_sequence_ids
msgid "Available sequences"
msgstr "Secuencias disponibles"
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid "Cancel"
msgstr "Cancelar"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__create_uid
msgid "Created by"
msgstr "Creado por"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__create_date
msgid "Created on"
msgstr "Creado el"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal__display_name
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move__display_name
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__display_name
msgid "Display Name"
msgstr "Nombre mostrado"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_bank_statement_line__entry_number
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move__entry_number
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line__entry_number
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_payment__entry_number
msgid "Entry Number"
msgstr "Número de asiento"
#. module: account_journal_general_sequence
#: model:ir.model.constraint,message:account_journal_general_sequence.constraint_account_move_entry_number_unique
msgid "Entry number must be unique per company."
msgstr "El número de asiento debe ser único por compañía."
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal__id
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move__id
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line__id
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__id
msgid "ID"
msgstr "ID"
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid ""
"If you have already filed and legalized your journals with the competent "
"authority, this action could change it. Continue?"
msgstr ""
"Si ya ha presentado y legalizado sus diarios ante la autoridad competente, "
"esta acción podría modificarlo. ¿Continuar?"
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_journal
msgid "Journal"
msgstr "Diario"
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_move
msgid "Journal Entry"
msgstr "Asiento contable"
#. module: account_journal_general_sequence
#: model:ir.model,name:account_journal_general_sequence.model_account_move_line
msgid "Journal Item"
msgstr "Apunte contable"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_journal____last_update
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move____last_update
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard____last_update
msgid "Last Modified on"
msgstr "Última modificación el"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__write_uid
msgid "Last Updated by"
msgstr "Última actualización por"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__write_date
msgid "Last Updated on"
msgstr "Última actualización el"
#. module: account_journal_general_sequence
#: code:addons/account_journal_general_sequence/wizards/account_move_renumber_wizard.py:0
#, python-format
msgid "No account moves found."
msgstr "No se ha encontrado ningún asiento contable."
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid "Renumber"
msgstr "Renumerar"
#. module: account_journal_general_sequence
#: model_terms:ir.ui.view,arch_db:account_journal_general_sequence.account_move_renumber_wizard_view_form
msgid "Renumber account entry numbers"
msgstr "Renumerar asientos contables"
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_renumber_wizard__starting_date
msgid "Renumber account moves starting this day."
msgstr "Renumerar asientos contables a partir de este día."
#. module: account_journal_general_sequence
#: model:ir.actions.act_window,name:account_journal_general_sequence.account_move_renumber_wizard_action
#: model:ir.ui.menu,name:account_journal_general_sequence.account_move_renumber_wizard_menu
msgid "Renumber journal entries"
msgstr "Renumerar asientos contables"
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_renumber_wizard__starting_number
msgid "Reset sequence to this number before starting."
msgstr "Reiniciar la secuencia a este número antes de empezar."
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__sequence_id
msgid "Sequence"
msgstr "Secuencia"
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_move_renumber_wizard__sequence_id
msgid ""
"Sequence to use for renumbering. Affects all journals that use this sequence."
msgstr ""
"Secuencia usada al renumerar. Afectará a todos los diarios que usen esta "
"secuencia."
#. module: account_journal_general_sequence
#: model:ir.model.fields,help:account_journal_general_sequence.field_account_journal__entry_number_sequence_id
msgid "Sequence used for account entry numbering."
msgstr "Secuencia usada para renumerar los asientos contables."
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__starting_date
msgid "Starting Date"
msgstr "Fecha de inicio"
#. module: account_journal_general_sequence
#: model:ir.model.fields,field_description:account_journal_general_sequence.field_account_move_renumber_wizard__starting_number
msgid "Starting Number"
msgstr "Número inicial"

View File

@ -0,0 +1,3 @@
from . import account_journal
from . import account_move
from . import account_move_line

View File

@ -0,0 +1,39 @@
# 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

View File

@ -0,0 +1,56 @@
# Copyright 2022 Moduon
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import logging
from odoo import api, fields, models
_logger = logging.getLogger(__name__)
class AccountMove(models.Model):
_inherit = "account.move"
_sql_constraints = [
(
"entry_number_unique",
"UNIQUE(entry_number, company_id)",
"Entry number must be unique per company.",
),
]
entry_number = fields.Char(
index=True,
readonly=True,
tracking=True,
store=True,
compute="_compute_entry_number",
help="Automatic numbering, based on journal configuration.",
)
@api.depends("state")
def _compute_entry_number(self):
"""Assign an entry number when posting."""
canceled = self.filtered_domain(
[("state", "=", "cancel"), ("entry_number", "!=", False)]
)
canceled.entry_number = False
if canceled:
no_gap_seqs = canceled.mapped(
"journal_id.entry_number_sequence_id"
).filtered_domain([("implementation", "=", "no_gap")])
if no_gap_seqs:
_logger.warning(
"Emptied entry_number for %r after cancellation. "
"This created gaps on %r.",
canceled,
no_gap_seqs,
)
chosen = self.filtered_domain(
[("state", "=", "posted"), ("entry_number", "=", False)]
)
for move in chosen.sorted(lambda one: (one.date, one.name, one.id)):
move.entry_number = move.journal_id.entry_number_sequence_id._next(
move.date
)
if chosen:
_logger.info("Added entry_number to %r", chosen)

View File

@ -0,0 +1,10 @@
# Copyright 2022 Moduon
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
entry_number = fields.Char(related="move_id.entry_number")

View File

@ -0,0 +1,13 @@
To configure journal sequences:
#. Have full accounting permissions.
#. Go to *Invoicing > Configuration > Accounting > Journals*.
#. Select or create the journal you want to configure.
#. Use *Account entry number sequence* to configure a sequence.
Note that:
* Various journals can share the same sequence.
* All journals get a shared default sequence, per company.
* Entry numbers must be unique per company. So, if you use different sequences
per journal, make sure they don't produce colliding results.

View File

@ -0,0 +1,2 @@
* Jairo Llopis (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)

View File

@ -0,0 +1,5 @@
This module extends the functionality of account to support sequenced entry
numbers and to allow you to renumber them if needed, on demand.
It adds a new field called *Entry number*. This is independent from the *Number*
that Odoo adds by default, and has different purpose.

View File

@ -0,0 +1,22 @@
To see journal entry numbers:
#. Go to *Invoicing > Accounting > Miscellaneous > Journal Entries*.
#. Notice the new field *Entry Number*. Only posted moves get an entry number.
Note that:
* You can use that new field in quick searches.
* You can see it also in *Invoicing > Accounting > Miscellaneous > Journal Items*.
To renumber journal entries:
#. Have full accounting permissions.
#. Have *Accounting / Invoicing / Billing Administrator* permissions.
#. Go to *Invoicing > Accounting > Actions > Renumber journal entries*.
#. Configure those parameters.
#. Click on *Renumber*.
Note that:
* You will only be able to select sequences related to journals.
* A sequence usually affects various journals, if not all.

View File

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_move_renumber_wizard,access_account_move_renumber_wizard,model_account_move_renumber_wizard,account.group_account_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_account_move_renumber_wizard access_account_move_renumber_wizard model_account_move_renumber_wizard account.group_account_manager 1 1 1 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -0,0 +1,468 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>General sequence in account journals</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="general-sequence-in-account-journals">
<h1 class="title">General sequence in account journals</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_journal_general_sequence"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_journal_general_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of account to support sequenced entry
numbers and to allow you to renumber them if needed, on demand.</p>
<p>It adds a new field called <em>Entry number</em>. This is independent from the <em>Number</em>
that Odoo adds by default, and has different purpose.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>To configure journal sequences:</p>
<ol class="arabic simple">
<li>Have full accounting permissions.</li>
<li>Go to <em>Invoicing &gt; Configuration &gt; Accounting &gt; Journals</em>.</li>
<li>Select or create the journal you want to configure.</li>
<li>Use <em>Account entry number sequence</em> to configure a sequence.</li>
</ol>
<p>Note that:</p>
<ul class="simple">
<li>Various journals can share the same sequence.</li>
<li>All journals get a shared default sequence, per company.</li>
<li>Entry numbers must be unique per company. So, if you use different sequences
per journal, make sure they dont produce colliding results.</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>To see journal entry numbers:</p>
<ol class="arabic simple">
<li>Go to <em>Invoicing &gt; Accounting &gt; Miscellaneous &gt; Journal Entries</em>.</li>
<li>Notice the new field <em>Entry Number</em>. Only posted moves get an entry number.</li>
</ol>
<p>Note that:</p>
<ul class="simple">
<li>You can use that new field in quick searches.</li>
<li>You can see it also in <em>Invoicing &gt; Accounting &gt; Miscellaneous &gt; Journal Items</em>.</li>
</ul>
<p>To renumber journal entries:</p>
<ol class="arabic simple">
<li>Have full accounting permissions.</li>
<li>Have <em>Accounting / Invoicing / Billing Administrator</em> permissions.</li>
<li>Go to <em>Invoicing &gt; Accounting &gt; Actions &gt; Renumber journal entries</em>.</li>
<li>Configure those parameters.</li>
<li>Click on <em>Renumber</em>.</li>
</ol>
<p>Note that:</p>
<ul class="simple">
<li>You will only be able to select sequences related to journals.</li>
<li>A sequence usually affects various journals, if not all.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_general_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>Moduon</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Jairo Llopis (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Rafael Blasco (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_journal_general_sequence">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1 @@
from . import test_numbering

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

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Moduon
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<data>
<record id="view_account_journal_tree" model="ir.ui.view">
<field name="name">Add move number sequence to tree</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_tree" />
<field name="arch" type="xml">
<field name="company_id" position="before">
<field name="entry_number_sequence_id" optional="hide" />
</field>
</field>
</record>
<record id="view_account_journal_form" model="ir.ui.view">
<field name="name">Add move number sequence to form</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="arch" type="xml">
<field name="refund_sequence" position="before">
<field name="entry_number_sequence_id" />
</field>
</field>
</record>
</data>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Moduon
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<data>
<record id="view_move_tree" model="ir.ui.view">
<field name="name">Add move number to tree</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_tree" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="entry_number" optional="show" />
</field>
</field>
</record>
<record id="view_move_form" model="ir.ui.view">
<field name="name">Add move number to form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='accounting_info_group']">
<field name="entry_number" />
</xpath>
<xpath expr="//group[@name='misc_group']">
<field name="entry_number" />
</xpath>
</field>
</record>
<record id="view_account_move_filter" model="ir.ui.view">
<field name="name">Add move number to search</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_account_move_filter" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="entry_number" />
</field>
</field>
</record>
</data>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Moduon
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<data>
<record id="view_move_line_tree" model="ir.ui.view">
<field name="name">Add move number to tree</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree" />
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="entry_number" optional="hide" />
</field>
</field>
</record>
<record id="view_move_line_form" model="ir.ui.view">
<field name="name">Add move number to form</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form" />
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="entry_number" />
</field>
</field>
</record>
<record id="view_account_move_line_filter" model="ir.ui.view">
<field name="name">Add move number to search</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_account_move_line_filter" />
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="entry_number" />
</field>
</field>
</record>
</data>

View File

@ -0,0 +1 @@
from . import account_move_renumber_wizard

View File

@ -0,0 +1,82 @@
# Copyright 2022 Moduon
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from datetime import date
from odoo import _, api, exceptions, fields, models
class AccountMoveRenumberWizard(models.TransientModel):
_name = "account.move.renumber.wizard"
_description = "Account move entry renumbering wizard"
starting_date = fields.Date(
required=True,
default=lambda self: self._default_starting_date(),
help="Renumber account moves starting this day.",
)
starting_number = fields.Integer(
default=1, help="Reset sequence to this number before starting."
)
available_sequence_ids = fields.Many2many(
comodel_name="ir.sequence",
string="Available sequences",
default=lambda self: self._default_available_sequence_ids(),
)
sequence_id = fields.Many2one(
comodel_name="ir.sequence",
string="Sequence",
required=True,
default=lambda self: self._default_entry_number_sequence(),
domain="[('id', 'in', available_sequence_ids)]",
help="Sequence to use for renumbering. Affects all journals that use this sequence.",
)
@api.model
def _default_starting_date(self):
"""Start by default on day 1 of current year."""
return date(date.today().year, 1, 1)
@api.model
def _default_entry_number_sequence(self):
"""Get default sequence if it exists."""
return self.env["ir.sequence"].search(
[("code", "=", "account_journal_general_sequence.default")]
)
@api.model
def _default_available_sequence_ids(self):
"""Let view display only journal-related sequences."""
return self.env["account.journal"].search([]).mapped("entry_number_sequence_id")
def action_renumber(self):
"""Renumber moves.
Makes sure moves exist. Sorts them. Resets sequences. Renumbers them.
"""
# Find posted moves that match wizard criteria
moves = self.env["account.move"].search(
[
("state", "=", "posted"),
("date", ">=", self.starting_date),
("journal_id.entry_number_sequence_id", "=", self.sequence_id.id),
],
order="date, id",
)
if not moves:
raise exceptions.UserError(_("No account moves found."))
# Reset sequence
future_ranges = self.env["ir.sequence.date_range"].search(
[
("date_from", ">", self.starting_date),
("sequence_id", "=", self.sequence_id.id),
]
)
future_ranges.unlink()
current_range = self.sequence_id._get_current_sequence(self.starting_date)
current_range.number_next_actual = self.starting_number
self.sequence_id.number_next_actual = self.starting_number
# Renumber the moves
moves.entry_number = False
moves.flush(["entry_number"])
moves._compute_entry_number()

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Moduon
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<data>
<record id="account_move_renumber_wizard_view_form" model="ir.ui.view">
<field name="name">Renumber form</field>
<field name="model">account.move.renumber.wizard</field>
<field name="arch" type="xml">
<form string="Renumber account entry numbers">
<sheet>
<group colspan="4">
<field name="starting_date" />
<field name="starting_number" />
<field name="available_sequence_ids" invisible="1" />
<field name="sequence_id" />
</group>
</sheet>
<footer>
<button
name="action_renumber"
type="object"
string="Renumber"
class="btn-primary"
confirm="If you have already filed and legalized your journals with the competent authority, this action could change it. Continue?"
/>
<button special="cancel" string="Cancel" class="btn-secondary" />
</footer>
</form>
</field>
</record>
<record id="account_move_renumber_wizard_action" model="ir.actions.act_window">
<field name="name">Renumber journal entries</field>
<field name="res_model">account.move.renumber.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
id="account_move_renumber_wizard_menu"
parent="account.menu_finance_entries_actions"
action="account_move_renumber_wizard_action"
/>
</data>