Skip to Content
Menu
This question has been flagged
1 Reply
6274 Views

Good night,

When creating a client I have the following validation that is generating problems for me. How can I do it to eliminate it?

nif field (vat)

release: odoo12

I do the following:

The NIF [xxxxxxxx] for the company [xxxxxxx.] does not appear to be valid. Note: the expected format is PERxxxxxxx or PED1xxxxxxxx

from odoo import api, fields, models



class ResPartner(models.Model):

    _inherit = 'res.partner'


    vies_passed = fields.Boolean(

        string="VIES validation",default=False, readonly=True)


    @api.model

    def simple_vat_check(self, country_code, vat_number):

        res = super(ResPartner, self).simple_vat_check(

            country_code, vat_number,

        )

        partner = self.env.context.get('vat_partner')

        if partner and self.vies_passed:

            # Can not be sure that this VAT is signed up in VIES

            partner.update({'vies_passed': False})

        return res


    @api.model

    def vies_vat_check(self, country_code, vat_number):

        partner = self.env.context.get('vat_partner')

        if partner:

            # If there's an exception checking VIES, the upstream method will

            # call simple_vat_check and thus the flag will be removed

            partner.update({'vies_passed': True})

        res = super(ResPartner, self).vies_vat_check(country_code, vat_number)

        if not res:

            return self.simple_vat_check(country_code, vat_number)

        return res


    @api.constrains('vat')

    def check_vat(self):

        for partner in self:

            partner = partner.with_context(vat_partner=partner)

            super(ResPartner, partner).check_vat()


    def check_vat_es(self, vat):

        return True


Avatar
Discard
Best Answer

Hello, 

Inside Invoice Setting there is setting "Verify VAT Numbers" which helps to verify VAT and if VAT is not valid then it raise this Warning. 

you can simply disable this setting in order to disable the warning. 

https://prnt.sc/rgbgi9

Thanks

Anisha Bahukhandi

Technical Content Writer

Avatar
Discard