Ir al contenido
Menú
Se marcó esta pregunta

I have a case :

I have two fields application_no1 & application_no2 in hr.employee table, I want to check if the employee's name and email are the same, then I want to set the field application_no1 equal field application_no2.

My issue is my function set the same number if the name or email are the same this is my code below:

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

        for record in self:

            rec = modelObj.search([('id_no', '=', record.id_no),('email', '=', record.email)])

            if rec:

                record.application_no1 = record.record.application_no2
            else:return True

Avatar
Descartar

Hello,

Do you want to change the domain to:

[('id_no', '!=', record.id_no),('email', '=', record.email), ('name', '=', record.name)]

As you only want records which are not the same as the record you are iterating through and where the name is the same?

Thanks,

Also, changing:

record.application_no1 = record.record.application_no2

to:

record.application_no1 = rec.application_no2 may help,

But a problem may arise if they have 3 records with the same name and email, there maybe another way to achieve what you are doing.

Could you specify your goal?

Thanks,

Autor

exactly, Do you have another way to achieve this?

Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 23
1545
2
sept 21
5497
1
jun 21
3888
1
jul 19
2924
5
jun 19
4193