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

Hello, I have 2 tables on those 2 tables I have 2 same fields called employee_id which are Many2Many fields so based on this I have to by default selected the value to the other table how can I achieve this?

Avatar
Discard

Hi there, can you explain a little bit more about the case.

Best Answer

Hi,

# Get the records you want to update

records = self.env['model_a'].search([])

# Get the employee IDs from model_b that you want to set for the records

employee_ids = self.env['model_b'].search([])

# Update the records

records.write({'employee_ids': [(4, employee_id) for employee_id in employee_ids]})

Regards

Avatar
Discard