In order to add an option to allow the importation of VAT numbers without validating them I'm trying to redefine the method check_vat. It is added to res_partner in the module base_vat (base_vat.py:114). This method is used to implement the constraint logic defined for the constraint on base_vat.py:150
_constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
To redefine this method I inherit res_partner as shown below:
class ags_res_partner(osv.osv):
_inherit = 'res.partner'
def check_vat(self, cr, uid, ids, context=None):
res = super(ags_res_partner, self).check_vat(cr, uid, ids, context=context)
#if parametro_comprobar_CIFS return res
print "redefined check_vat"
return True
def simple_vat_check(self, cr, uid, country_code, vat_number, context=None):
print "redefined simple_vat_check"
return True
ags_res_partner()
The result is that the redefined version of simple_vat_check (a method called from inside check_vat) gets invoked but not check_vat. Debugging this code I find that the inheritance is working. In fact, I can see my class in self.__class__.__mro__ when inside the check_vat implementation of base_vat. The problem comes from the way that the constraint methods get called (orm.py:1527), skipping the OpenERP managed inheritance system. Once inside check_vat, simple_vat_check gets invoked properly taking into account that inheritance system.
Since check_vat is defined as a public method, I understand it should be redefinable. Am I wrong? Did I commit any mistake or the fact that the inheritance gets skipped is just a bug?
Thanks in advance