跳至内容
菜单
此问题已终结

Hello odoo community,

I have a weird issue im trying to apply onchange function to res.partner zip field

Nothing happens when im trying to change zip  field , but if i choose some other field or apply the same function to a button, it would work ...

I dont understand what the issue is ...

New api code example:

@api.one

@api.onchange('zip')

def validate_uk_postcode(self):

for record in self:

if record.country_id.id==233:

zip=record.zip.upper()

zip_in_line=s = zip.replace(" ", "") 

self.env.cr.execute("select postcode from ct_uk_postcodes_ct_uk_postcodes where postcode='{0}'".format(zip_in_line))

res2 = self.env.cr.fetchone()

if res2==None:

raise ValidationError("Post Code is invalid, Please make sure that country and post code is correct!")

results:

Nothing happen

Also i tryed to use old api

Old api example:

def onchange_zipcode(self, cr, uid, ids, context=None):

for record in self.browse(cr,uid,ids):

if record.country_id.id==233: 

zip=record.zip.upper()

zip_in_line=s = zip.replace(" ", "")

cr.execute("select postcode from ct_uk_postcodes_ct_uk_postcodes where postcode='{0}'".format(zip_in_line))

res = cr.fetchone()

if res==None: 

raise ValidationError("Post Code is invalid, Please make sure that country and post code is correct!")

result:

Nothing Happens

Xml

<field name="zip" placeholder="ZIP" style="width: 20%%" attrs="{'readonly': [('use_parent_address','=',True)]}" on_change="onchange_zipcode()"/> 


Thank you,

形象
丢弃
相关帖文 回复 查看 活动
1
2月 21
5642
1
6月 15
5042
2
4月 25
2973
3
11月 24
17976
1
11月 22
3181