From 1b00a0b52b20694d91dbe9d0ec7dbda4bc419dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 29 Jan 2021 16:03:44 +0000 Subject: [PATCH] [IMP] partner_autocomplete: enrich companies at creation In addition to enriching companies on the fly, we also enrich companies when creating them. It allows to have an enrich on companies existing before using autocomplete, and have results of enrich directly at create for companies created after installing this module. LINKS Task ID-2322455 PR #64600 PR odoo/upgrade#2086 Co-Authored-By: David Beguin Co-Authored-By: Thibault Delavallee --- addons/partner_autocomplete/models/res_company.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/partner_autocomplete/models/res_company.py b/addons/partner_autocomplete/models/res_company.py index 119787209d1..86c6e0c9bf7 100644 --- a/addons/partner_autocomplete/models/res_company.py +++ b/addons/partner_autocomplete/models/res_company.py @@ -3,6 +3,7 @@ import json import logging +import threading from odoo.addons.iap.tools import iap_tools from odoo import api, fields, models, tools, _ @@ -23,6 +24,13 @@ class ResCompany(models.Model): for company in self: company.partner_id.partner_gid = company.partner_gid + @api.model_create_multi + def create(self, vals_list): + res = super().create(vals_list) + if not getattr(threading.currentThread(), 'testing', False): + res.iap_enrich_auto() + return res + def iap_enrich_auto(self): """ Enrich company. This method should be called by automatic processes and a protection is added to avoid doing enrich in a loop. """