Skip to Content
Menu
This question has been flagged
1 Reply
4898 Views

Hello,
Actually i'm working in a project ( i want to update a customer instead of creating it ) 
i did this code but it doesn't work any idea !! 

if record.email:

  contact = env['res.partner'].search([['email', '=', record.email]])


  if contact:

    for c in contact:

      if c.id != record.id :

        records.update({

          'mobile': record.mobile,

          'phone' : '22'

          

        })


Avatar
Discard
Author
@Akshay Babu yhanks , but instead of updating the contact .. another conctact created with updated info ... is there any solution ?
Best Answer

To update an already created customer, you should be updating "c" instead of "records"

if contact:

    for c in contact:

      if c.id != record.id :

        c.write({

          'mobile': record.mobile,

          'phone' : '22'

          

        })


Avatar
Discard
Related Posts Replies Views Activity
3
Mar 23
14803
1
Jan 23
954
1
May 24
1433
3
Nov 23
15311
3
Nov 24
21075