Skip to content
Snippets Groups Projects
Commit 74ea1653 authored by Hoang Tran's avatar Hoang Tran
Browse files

[IMP] account_check_printing: improve perf of computed preferred pm


When install the module on a db with huge amount of account move,
prefetching data when accessing partner_id of first move iteration is
costly and should be avoided.

closes odoo/odoo#84989

X-original-commit: c80700ee
Signed-off-by: default avatarWilliam André (wan) <wan@odoo.com>
parent 4340a7e4
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
from odoo import models, fields, api
from odoo.tools.sql import column_exists, create_column
class AccountMove(models.Model):
......@@ -15,6 +16,15 @@ class AccountMove(models.Model):
store=True,
)
def _auto_init(self):
""" Create column for `preferred_payment_method_id` to avoid having it
computed by the ORM on installation. Since `property_payment_method_id` is
introduced in this module, there is no need for UPDATE
"""
if not column_exists(self.env.cr, "account_move", "preferred_payment_method_id"):
create_column(self.env.cr, "account_move", "preferred_payment_method_id", "int4")
return super()._auto_init()
@api.depends('partner_id')
def _compute_preferred_payment_method_idd(self):
for move in self:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment