Skip to content
Snippets Groups Projects
Commit 1b00a0b5 authored by Thibault Delavallée's avatar Thibault Delavallée
Browse files

[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: default avatarDavid Beguin <dbe@odoo.com>
Co-Authored-By: default avatarThibault Delavallee <tde@odoo.com>
parent 97f29578
Branches
Tags
No related merge requests found
......@@ -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. """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment