2
0
account-financial-tools/account_journal_general_sequence
Jairo Llopis 4e15e63732
[FIX] account_journal_general_sequence: optimize recomputes when renumbering
When calling `_next()` in a sequence, it issues calls to `search()`, especially if it is a no-gap or date-range-based sequence (which is common in this use case).

When doing a search, Odoo triggers recomputations. Thus, when doing both a write and a call to `_next()` in the same loop, Odoo had to flush to DB too often, causing a bottleneck.

Now, the process is more optimized:
1. Cache all new entry numbers.
2. Write them all.
3. Mark them all as modified at once, to batch-trigger recomputations.

To reduce the amount of recomputations, tracking is disabled for the entry number. After all, before renumbering there's already a warning telling you that you shouldn't renumber if you already published those entry numbers to your fiscal authority.

Another pseudo-improvement is that the info log is shorter. Enable debug logging to log the list of IDs changed.

A test was failing because it was relying on the fact that computations were not getting as lazy as they should. Manual flushes are added to imitate a user doing different invoice creations.

@moduon MT-3082
2023-06-26 13:50:12 +01:00
..
i18n Update translation files 2023-06-23 11:47:29 +00:00
models [FIX] account_journal_general_sequence: optimize recomputes when renumbering 2023-06-26 13:50:12 +01:00
readme [FIX] account_journal_general_sequence: bottleneck at install 2022-12-23 10:22:43 +00:00
security [ADD] account_journal_general_sequence: account move entry sequence 2022-12-23 10:22:43 +00:00
static/description [UPD] README.rst 2022-12-23 11:21:55 +00:00
tests [FIX] account_journal_general_sequence: optimize recomputes when renumbering 2023-06-26 13:50:12 +01:00
views [MIG] account_journal_general_sequence: v16 modifications 2022-12-23 10:47:11 +00:00
wizards [FIX] account_journal_general_sequence: avoid renaming bottleneck 2023-04-24 10:09:27 +01:00
__init__.py [ADD] account_journal_general_sequence: account move entry sequence 2022-12-23 10:22:43 +00:00
__manifest__.py account_journal_general_sequence 16.0.1.0.4 2023-06-23 11:47:09 +00:00
README.rst [UPD] README.rst 2022-12-23 11:21:55 +00:00

====================================
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/16.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-16-0/account-financial-tools-16-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/16.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:

Installation
============

After installing this module, no entry numbers will be generated because that
could have a very negative impact in installations that already had a lot of
account moves.

If you need to add numbers to preexisting account moves, please use the
renumbering wizard as explained in the *Usage* section.

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:%2016.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.

.. |maintainer-yajo| image:: https://github.com/yajo.png?size=40px
    :target: https://github.com/yajo
    :alt: yajo

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-yajo| 

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_journal_general_sequence>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.