Purpose ======= Avoid creating / enriching multiple time the same company. It can occur in many situation; when IAP do not return an email address the the company, when the domain is blacklisted... We also want to remove the field "iap_enrich_info" from the res.partner model because this field can be heavy (JSON field) and the res.partner model is used a lot. Technical ========= For this purpose, we create a new model <res.partner.iap> which will store the IAP response and the requested domain. So we can retrieve the previously enriched company regardless of the partner's values Task 2466653 See odoo/odoo/pull/68286 See odoo/upgrade/pull/2301 closes odoo/odoo#68286 Related: odoo/upgrade#2301 Related: odoo/enterprise#17426 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class ResPartnerIap(models.Model):
|
|
"""Technical model which stores the response returned by IAP.
|
|
|
|
The goal of this model is to not enrich 2 times the same company. We do it in a
|
|
separate model to not add heavy field (iap_enrich_info) on the <res.partner>
|
|
model.
|
|
|
|
We also save the requested domain, so whatever the values are on the <res.partner>,
|
|
we will always retrieve the already enriched <res.partner> and the corresponding
|
|
IAP information.
|
|
"""
|
|
|
|
_name = 'res.partner.iap'
|
|
_description = 'Partner IAP'
|
|
|
|
partner_id = fields.Many2one('res.partner', string='Partner', help='Corresponding partner',
|
|
ondelete='cascade', required=True)
|
|
iap_search_domain = fields.Char('Search Domain / Email', help='Domain used to find the company')
|
|
iap_enrich_info = fields.Text('IAP Enrich Info', help='IAP response stored as a JSON string', readonly=True)
|
|
|
|
_sql_constraints = [('unique_partner_id', 'UNIQUE(partner_id)', 'Only one partner IAP is allowed for one partner')]
|