[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 <dbe@odoo.com> Co-Authored-By: Thibault Delavallee <tde@odoo.com>
This commit is contained in:
co-authored by
David Beguin
parent
97f2957821
commit
1b00a0b52b
@@ -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. """
|
||||
|
||||
Reference in New Issue
Block a user