콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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

아바타
취소

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,

작성자

exactly, Do you have another way to achieve this?

관련 게시물 답글 화면 활동
0
1월 23
1581
2
9월 21
5619
1
6월 21
3987
1
7월 19
3033
5
6월 19
4234