Skip to Content
Menu
This question has been flagged
2 Replies
3895 Views

I'm working with odoo v11.​

I need to bypass VAT number validation that is done by res.partner in module base_vat.

@api.constrains('vat', 'commercial_partner_country_id')
def check_vat(self):
...

I've done a new module with this python code:

class ResPartner(models.Model):
_inherit = 'res.partner'
    @api.constrains('vat', 'commercial_partner_country_id')
def check_vat(self):
return True

But it doesn't work as far original check_vat  is still executed and not overwrited. I know I need to delete or bypass previous constraint_methods but I don't know how.

Any advice?

Avatar
Discard

Hell Quim,

The way you overwrite the method is perfect.

PS - Just make sure you added this file in your __init__.py file. and also check whether module installed successfully !

Thanks,

Dipak

Best Answer

Hi,

Everything seems perfect but you have to add "base_vat" to depends in __manifest__.py because you want to override check_vat method in res.partner in base_vat module.

'depends': ['base_vat']

 

Avatar
Discard
Author

Yes you're right! I thought that dependencies on manifest only was important to ensure wich modules have to be installed before installing. But I see that it's important to determine overwrites too.

Thks a lot