Skip to Content
Menu
This question has been flagged

can anyone help me about the function below:

modelObj = self.env['hr.employee']

        for record in self:

            rec = modelObj.search([('name, '=', record.name),('passport_id', '=', record.passport_id)])

            if len(rec) > 1:

                ''' I need here all employees with the same name&passport to be same                                  sequence number '''

            else: self['code1'] = self.env['ir.sequence'].next_by_code('new_code1') or _('New')             

Avatar
Discard
Best Answer

H,

  Please make appropriate changes.

You can refer 

modelObj = self.env ['hr.employee']

        for employee in self:

            employee_id = modelObj.search ([('name', '=', employee.name), ('passport_id', '=', employee.passport_id)])


            if employee_id:

                employee.write ({

                    'sequence number': employee_id [0] .sequence_number

                })

            else:

                 sequence = self.env ['ir.sequence']. next_by_code ('new_code1')

                employee.write ({

                    'sequence number': sequence

                })

Avatar
Discard
Related Posts Replies Views Activity
2
Apr 21
3415
2
Jun 19
2902
3
Dec 21
7931
7
Sep 21
25971
0
Jun 21
2007