File: res_partner_iap.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (27 lines) | stat: -rw-r--r-- 1,075 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- 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',
                                 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')]