hi,
I am creating a call log module , and i need to automatically get the partner information by the given number ie. the system have to automatically search and fetch the partner and assign it to a field .
Somebody please help me with the python code , my code is :
customer_number = fields.Char(string='Customer Number', track_visiility='onchange', onchange='get_partner()', store=True)
customer_id = fields.Many2one('res.partner', string='Customer', track_visibility='onchange',index=True,
help="Linked partner (optional). Usually created when converting the lead.", store=True)
#--------------------------------------------------
# Api s
#--------------------------------------------------
@api.onchange('customer_number')
def get_partner(self):
if self.customer_number:
partner = self.env['res.partner'].search_read([('self.customer_number', 'ilike', 'self.phone')])
self.customer_id = partner
return self.customer_id