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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
745
Views
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Hi there, can you explain a little bit more about the case.