THIS CODE RUN
def name_get(self):
def _name_get(d):
name = d.get('name', '')
identity_no = d.get('identity_no', '')
reg = '%s ( %s )' % (name, identity_no)
return (d['id'], reg)
result = list(map(_name_get, self.read(['name', 'identity_no'])))
return result
BUT I WANT GIVE A CONDITION LIKE THIS
@api.multi
def name_get(self):
if self.identity_no != False :
def _name_get(d):
name = d.get('name', '')
identity_no = d.get('identity_no', '')
reg = '%s ( %s )' % (name, identity_no)
return (d['id'], reg)
result = list(map(_name_get, self.read(['name', 'identity_no'])))
else :
def _name_get(d):
name = d.get('name', '')
return (d['id'], name)
result = list(map(_name_get, self.read(['name'])))
return result
File "/home/ubuntu/mycompany/addons/v11_company_custom/base/partner.py", line 44, in name_get if self.identity_no != False : File "/home/ubuntu/mycompany/gigerhe/fields.py", line 935, in __get__ record.ensure_one() File "/home/ubuntu/mycompany/gigerhe/models.py", line 4365, in ensure_one raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: res.partner(857, 825, 77, 83, 69, 42, 840, 806)
Odoo Tips and Development Guide: https://plus.google.com/collection/4UX8UE