I have a simple onchange function in which I am writing to a few fields. But the value returned as "vals" isn't getting to the frontend. The values returned in the network tab for Here is the function:
@api.multi
@api.onchange('email')
def onchange_email(self):
vals = {}
contactid = ""
siteid = ""
respartner = self.env['res.partner'].search([('id','=',self._origin.id)])
for partner in respartner:
for site in partner.company_site_lines:
if site.company_corporate:
site.email = self.email.upper()
site.write({"email":self.email.upper()})
for contact in partner.contact_ids:
if contact.flag_first_contact:
contactid = contact.id
contact.email = self.email.upper()
contact.site_email = self.email.upper()
contact.write({'email':self.email.upper(),'site_email':self.email.upper()})
self.write({'contact_ids':[(1,contact.id,{'email':self.email.upper(),'site_email':self.email.upper()})]})
partner.email = self.email.upper()
partner.write({'email':self.email.upper()})
vals['email'] = partner.email
vals['active_tabs'] = partner.active_tabs
ressite = self.env['company.site'].search([('company_site_id','=',partner.id)])
vals['contact_ids'] = self._origin.contact_ids
#Printing vals['contact_ids'] gives the proper one2many field with the correct id: partner.contact(475,)
#But the output in chrome is:
# {"jsonrpc": "2.0",
# "id": 427040437,
# "result": {
# "value": {
# "contact_ids": [
# [5]
# ],
# .
# .
# .
# .
return {'value':vals}
# Is there something wrong with the way I am returning Values?
@Prakash, (Didn't have enough karma to comment.) Yes, that can be done, but that is not what I was looking for. I was looking to return the vals.