Reputation: 3907
I have this wizard method:
@api.multi
def search_partner_seniat(self):
""" Check vat of the partner and update iva rate
"""
self.ensure_one()
vat = self.vat.upper()
res = {
'name': _('The requested contributor does not exist'),
'vat_subjected': False,
'vat': vat,
'wh_iva_agent': False,
'wh_iva_rate': 0.0
}
if 'VE' in vat:
vat = vat[2:]
# assumption: both methods in new api style
if self.env['res.partner'].check_vat_ve(vat):
update_vals = self.env['seniat.url']._dom_giver(vat)
if update_vals:
res.update(update_vals) #self.write(res)
return {
'type': 'ir.actions.act_window',
'res_model': 'search.info.partner.seniat',
'view_mode': 'form',
'view_type': 'form',
'res_id': self.id,
'views': [(False, 'form')],
'target': 'new',
}
This is a wizard that should check for a specific vat
and show me the results of it, otherwise it shows this message The requested contributor does not exist
Howver, this is a migration I'm doing from v8 to v10 community.
So at this moment, it isn't returning anything, seems like it's not checking the table or something.
This method calls check_vat_ve
and _dom_giver
methods, which are like this:
@api.multi
def _dom_giver(self, vat):
""" Check and validates that the vat is a passport,
id or rif, to send information to SENIAT and returns the
partner info that provides.
"""
name = ''
url_seniat = ''
url_obj = self.search([], limit=1)
if url_obj.name:
name = url_obj.name
if url_obj.url_seniat:
url_seniat = url_obj.url_seniat
url1 = name + '%s'
url2 = url_seniat + '%s'
vat = self._validate_rif(vat)
if vat:
return self._get_rif(vat, url1, url2)
else:
return False
@api.model
def check_vat_ve(self, vat): #, context=None
""" Check Venezuelan VAT number, locally called RIF.
RIF: JXXXXXXXXX RIF VENEZOLAN
IDENTIFICATION CARD: VXXXXXXXXX
FOREIGN IDENTIFICATION CARD: EXXXXXXXXX
"""
#if context is None:
#context = {}
if re.search(r'^[VJEGP][0-9]{9}$', vat):
return True
if re.search(r'^([VE][0-9]{1,8}|[D][0-9]{9})$', vat):
return True
return False
All these methods originally looked like this:
def search_partner_seniat(self, cr, uid, ids, context=None):
""" Check vat of the partner and update iva rate
"""
if context is None:
context = {}
this = self.browse(cr, uid, ids)[0]
su_obj = self.pool.get('seniat.url')
rp_obj = self.pool.get('res.partner')
vat = this.vat.upper()
res = {'name': _('The requested contributor does not exist'),
'vat_subjected': False, 'vat': vat, 'wh_iva_agent': False,
'wh_iva_rate': 0.0}
if 'VE' in vat:
vat = vat[2:]
if rp_obj.check_vat_ve(vat, context=context):
res = su_obj._dom_giver(cr, uid, vat, context)
self.write(cr, uid, ids, res)
return {
'type': 'ir.actions.act_window',
'res_model': 'search.info.partner.seniat',
'view_mode': 'form',
'view_type': 'form',
'res_id': this.id,
'views': [(False, 'form')],
'target': 'new',
}
def check_vat_ve(self, vat, context=None):
""" Check Venezuelan VAT number, locally called RIF.
RIF: JXXXXXXXXX RIF VENEZOLAN
IDENTIFICATION CARD: VXXXXXXXXX
FOREIGN IDENTIFICATION CARD: EXXXXXXXXX
"""
if context is None:
context = {}
if re.search(r'^[VJEGP][0-9]{9}$', vat):
return True
if re.search(r'^([VE][0-9]{1,8}|[D][0-9]{9})$', vat):
return True
return False
def _dom_giver(self, cr, uid, vat, context=None):
""" Check and validates that the vat is a passport,
id or rif, to send information to SENIAT and returns the
partner info that provides.
"""
if context is None:
context = {}
url_obj = self.browse(cr, uid, self.search(cr, uid, []))[0]
url1 = url_obj.name + '%s'
url2 = url_obj.url_seniat + '%s'
vat = self._validate_rif(cr, uid, vat, context=None)
if vat:
return self._get_rif(cr, uid, vat, url1, url2, context=context)
else:
return False
It is working as expected on Odoo v8 of course.
Any ideas?
I think it has something to do with these declarations on _dom_giver
:
name = ''
url_seniat = ''
But I'm not really sure.
Upvotes: 1
Views: 81
Reputation: 14746
In your old version code you are writing wizard record.
self.write(cr, uid, ids, res)
In new version code write line is in comment.
#self.write(res)
In new version code vals are preparing but it is not use.
You should remove comment in write method & check it.
This may help you.
Upvotes: 1