python 3.x - How to modify the one2many or many2one field in other model odoo10 -


can 1 tell example how modify field in model if changed in type-one2many field.

for example, have 2 models a) hr_shifts b)hr_contract in hr_shifts there one2many field(emp_name_ids) when changed in fields reflect in hr_contract after click on save button. code work, when used in one2many field (emp_name_ids) doesn't work

@api.depends('schedule')     def _onchange_schedule(self):         item in self.hr_shifts_line:         current=self.env['hr.contract'].search([('employee_id','=',item.emp_name_ids.id)])         current.write({'working_hours':self.schedule.id}) 

one2many , many2many use special "commands" format manipulate set of records stored in/associated field.

you should try:

current.write({'emp_name_ids': [(6, 0, [ids])]}) 

for more info regarding special commands see docs: https://www.odoo.com/documentation/10.0/reference/orm.html#model-reference.

scroll bit down crud section there find possible commands ((6, _, ids) 1 of few more).


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -