Vauxoo / odoo

Fork of Odoo (formerly OpenERP). [This project is not publically mantained just born for internal usage with some little patches] go to official repository on github.com/odoo/odoo
https://www.odoo.com
Other
9 stars 9 forks source link

[IMP] account: Unlinking Journal Entries & Items SpeedUp #351

Closed hbto closed 2 years ago

hbto commented 4 years ago

[IMP] account: while unlinking Journal Entries & Journal Items several checks are made all over the records. Some of the checks were O(2) Other were quite repetitive and could be achieved without for loops.

Main

l10n_mx_avoid_reversal_entry module has become an integral part of Mexican Localization in OnPremise and/or SH Implementations. The reason is that users have found quite useful avoiding the reversal Journal Entries created by the default implementation of Account Partial Reconcile unlink() method and Account Full Reconcile unlink() method which for accountant people is the source of many troubles.

Every time a user cancels a payment with a huge amount of invoices which has several partial reconciliations (APRs) these leads to either of this scenarios:

Odoo's Original Implementation: the creation of a huge amount of Reversal Entries for the CABA Journal Entries related to each APR. This feature is undesirable in Mexican Localization as it leads to too much hassle to analyze the DIOT report. And in case of full reconciliation the reversal of the FX Journal Entries which is another issue for Mexicans who by law are abode to pay Taxes when Gains are recognized in a monthly basis, this reversal becomes dirty entries to analyze. l10n_mx_avoid_reversal_entry Implementation: the deletion of all the CABA Journal Entries related to the APRs and the FX Journal Entries in case of full reconciliation. Our scenario is the second, however, this affect every other one who deletes Journal Entries in mass in Odoo. Hence everybody is affected by this performance issue.

Conclusion

While unlinking Journal Entries & Journal Items several checks are made all over the records. Some of the checks were O(2) Other were quite repetitive and could be achieved without for loops. The main issue that we have found has been the duplicated use of _update_check both in Journal Entries and Items.

-- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr