[IMP] *: optimize code with search_fetch() and fetch()

closes odoo/odoo#112126

Related: odoo/enterprise#36782
Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
Raphael Collet
2023-03-05 15:12:57 +01:00
parent 8c81074e60
commit 6ef3772847
22 changed files with 129 additions and 105 deletions
@@ -13,7 +13,7 @@ class ResCompany(models.Model):
)
existing_companies = companies.exists()
# prefetch both fields
existing_companies.read(["fiscalyear_last_day", "fiscalyear_last_month"])
existing_companies.fetch(["fiscalyear_last_day", "fiscalyear_last_month"])
results = []
for data, company in zip(payload, companies):