Skip to Content
Menu
This question has been flagged
1 Atsakyti
5718 Rodiniai

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'

          

        })


Portretas
Atmesti
Autorius
@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'

          

        })


Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
4
gruod. 24
18278
1
saus. 23
1950
1
geg. 24
3380
3
lapkr. 23
17584
3
lapkr. 24
25286