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

Hello , 

I want to edit the purchase order name in function to the partner name 

I inherited create method and it works just for the first time when creating the PO

I tested with onchange but it works just before clicking on Save button 

This is my onchange method

@api.onchange('partner_id')
def change_code_purchase_order(self):
self.name = self.partner_id.name

Does anyone know how to fix it ?

Avatar
Discard
Best Answer

You can override create for the new created POs and override write method for change exists POs


def write(self, vals):
if 'partner_id' in vals:
partner = self.env['res_partner'].browse(vals.get('partner_id'))
vals['name'] = partner.name
return super().write(vals)


Avatar
Discard
Author

Yep , it works

Thank youu Waleed