Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
5371 Visualizzazioni

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
Abbandona

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,

Autore

exactly, Do you have another way to achieve this?

Post correlati Risposte Visualizzazioni Attività
0
gen 23
1545
2
set 21
5495
1
giu 21
3870
1
lug 19
2923
5
giu 19
4193