mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] account_journal_general_sequence: bottleneck at install
On databases with big amounts of account moves, installation would freeze Odoo for some minutes. We skip now entry number computation at install, to avoid such cases. @moduon MT-676
This commit is contained in:
@@ -6,6 +6,8 @@ from odoo import api, fields, models
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
ADDON = "account_journal_general_sequence"
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
@@ -30,6 +32,15 @@ class AccountMove(models.Model):
|
||||
@api.depends("state")
|
||||
def _compute_entry_number(self):
|
||||
"""Assign an entry number when posting."""
|
||||
# Skip if installing module, for performance reasons
|
||||
if self.env.context.get("module") == ADDON:
|
||||
module = self.env["ir.module.module"].search([("name", "=", ADDON)])
|
||||
if module.state == "to install":
|
||||
_logger.info(
|
||||
"Skipping entry number generation at install for %s.",
|
||||
self,
|
||||
)
|
||||
return
|
||||
canceled = self.filtered_domain(
|
||||
[("state", "=", "cancel"), ("entry_number", "!=", False)]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user