1
votes

I have a many2many field employee_idv01, How Can I create records for planning model with each employee.

for example if record.employee_idv01 === hr.employee(6,3) I need to create a record for hr.employee(6) and another for hr.employee(3)

    @api.model
    def create(self, vals):
        record = super(affectation3, self).create(vals)
        if record.employee_idv01:
            for i in self.employee_idv01??:


(how can I create records for planning with each employee???)

            self.env['planning'].create({
                                     'employee_id': record.????,
                                     'date_r01': record.date_r1,
                                     'date_r02': record.date_r2,
  

                             })           
1

1 Answers

1
votes

you can try this code:

 for employee in self.employee_idv01:
      self.env['planning'].create({
                                'employee_id': employee.id,
                                'date_r01': record.date_r1,
                                'date_r02': record.date_r2,
                              })