Files
odoo_source/addons/l10n_be/models/res_partner.py
T
Ricardo Gomes Rodrigues (rigr) c4bfaf3336 [IMP] base,l10n_be: move the company_registry from res_company to res_partner
This commit:
- moves the "Company Registry Number" from `res_company` to `res_partner` (which might be different from the VAT in some localizations). This must be unique among all partners of the same country.
- allows the search of partner by using their "VAT" or their "Company Registry Number"

Task-id: 2857253

Community PR: odoo#91938
Enterprise PR: odoo/enterprise#27605
Upgrade PR: odoo/upgrade#3570

closes odoo/odoo#91938

Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2022-06-20 18:56:10 +02:00

21 lines
819 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved.
from odoo import api, models
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.depends('vat', 'country_id')
def _compute_company_registry(self):
# OVERRIDE
# If a belgian company has a VAT number then it's company registry is it's VAT Number (without country code).
super()._compute_company_registry()
for partner in self.filtered(lambda p: p.country_id.code == 'BE' and p.vat):
vat_country, vat_number = self._split_vat(partner.vat)
if vat_country == 'be' and self.simple_vat_check(vat_country, vat_number):
partner.company_registry = vat_number