Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1713 Vistas

Hi,

We are using agencies to recruit people. They send in CV and applications and we create the application in the recruitment app. We want to see if an already refused applicant has been sent in by another agency. How do we filter to look for duplicates in both active and refused applicants at the same time?

Regards,

Tord Røsstad 

Avatar
Descartar
Mejor respuesta

Hello Tord Røsstad,


I trust you're doing well.


For scenarios like this, you have two approaches: utilising automated actions or implementing a create method. I'll explain both methods below.

Please find code in comment. 

For creating an automated action, please refer to the attached screenshot.

If you have any questions or need further clarification, feel free to ask.

I hope this will help you.
Thanks & Regards,
Email:    odoo@aktivsoftware.com     

Skype: kalpeshmaheshwari

Avatar
Descartar

Please find code here :-
Using the create method:
class Applicant(models.Model):
_inherit = "hr.applicant"

@api.model_create_multi
def create(self, vals_list):
records = super(Applicant, self).create(vals_list)
for record in records:
partner_names = self.env['hr.applicant'].search([('partner_name', 'ilike', record.partner_name), ('active', 'in', [True, False])]).mapped('partner_name')
if len(partner_names) > 1:
raise UserError('You Cannot Create the Same Applicant')
return records

Autor

Hello Jainesh,

This is great, thank you!
The only adjustment we need to make is that the client should be able to create applications with the same applicants name, as two people can share the same name. How do we make the user aware of a potential duplicate upon creation, but still let them create it if necessary (remove the blocker of UserError)?

Kind regards,
Tord Røsstad

Publicaciones relacionadas Respuestas Vistas Actividad
3
mar 24
2482
2
dic 15
2856
2
dic 23
2479
1
nov 21
4044
3
ene 16
6072