[IMP] account : defaults belgian company registry to vat number
In Belgium, the company registry and the VAT number (no country code) are identic. The company registry field is not mandatory, but is needed to export the belgian Intrastat XML file. Now: - belgian company registry is set by default to vat number. - missing company registry warning message redirects to company settings. closes odoo/odoo#58047 Task: 2335088 Related: odoo/enterprise#15270 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -4,3 +4,4 @@
|
||||
from . import account_chart_template
|
||||
from . import account_journal
|
||||
from . import account_move
|
||||
from . import res_company
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# -*- 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 ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
@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(ResCompany, self)._compute_company_registry()
|
||||
for company in self.filtered(lambda comp: comp.country_id.code == 'BE' and comp.vat):
|
||||
vat_country, vat_number = self.env['res.partner']._split_vat(company.vat)
|
||||
if vat_country == 'be' and self.env['res.partner'].simple_vat_check(vat_country, vat_number):
|
||||
company.company_registry = vat_number
|
||||
@@ -85,7 +85,7 @@ class Company(models.Model):
|
||||
mobile = fields.Char(related='partner_id.mobile', store=True, readonly=False)
|
||||
website = fields.Char(related='partner_id.website', readonly=False)
|
||||
vat = fields.Char(related='partner_id.vat', string="Tax ID", readonly=False)
|
||||
company_registry = fields.Char()
|
||||
company_registry = fields.Char(compute='_compute_company_registry', store=True, readonly=False)
|
||||
paperformat_id = fields.Many2one('report.paperformat', 'Paper format', default=lambda self: self.env.ref('base.paperformat_euro', raise_if_not_found=False))
|
||||
external_report_layout_id = fields.Many2one('ir.ui.view', 'Document Template')
|
||||
base_onboarding_company_state = fields.Selection([
|
||||
@@ -116,6 +116,11 @@ class Company(models.Model):
|
||||
return dict((fname, partner[fname])
|
||||
for fname in self._get_company_address_field_names())
|
||||
|
||||
def _compute_company_registry(self):
|
||||
# exists to allow overrides
|
||||
for company in self:
|
||||
company.company_registry = company.company_registry
|
||||
|
||||
# TODO @api.depends(): currently now way to formulate the dependency on the
|
||||
# partner's contact address
|
||||
def _compute_address(self):
|
||||
|
||||
Reference in New Issue
Block a user