-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] hr_applicant_duplicate: Onchange in phone and email to see if t…
…he applicant is duplicated or discarded.
- Loading branch information
Tu Nombre
committed
Jul 16, 2021
1 parent
48b855a
commit bf9a5fd
Showing
9 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
====================== | ||
Hr applicant duplicate | ||
====================== | ||
|
||
* Onchange in phone and email to see if the applicant is duplicated or discarded. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/hr-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Berezi Amubieta <[email protected]> | ||
* Alfredo de la Fuente <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2021 Berezi - Iker - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Hr Applicant Duplicate", | ||
'version': '14.0.1.0.0', | ||
"author": "Avanzosc", | ||
"category": "Sales", | ||
"depends": [ | ||
"hr_recruitment", | ||
], | ||
"data": [ | ||
], | ||
"license": "AGPL-3", | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * hr_applicant_duplicate | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-07-16 10:15+0000\n" | ||
"PO-Revision-Date: 2021-07-16 10:15+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model,name:hr_applicant_duplicate.model_hr_applicant | ||
msgid "Applicant" | ||
msgstr "Candidato" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0 | ||
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0 | ||
#, python-format | ||
msgid "Applicant duplicated or discarded." | ||
msgstr "Candidato duplicado o descartado." | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model.fields,field_description:hr_applicant_duplicate.field_hr_applicant__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model.fields,field_description:hr_applicant_duplicate.field_hr_applicant__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model.fields,field_description:hr_applicant_duplicate.field_hr_applicant____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última modificación el" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * hr_applicant_duplicate | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-07-16 10:15+0000\n" | ||
"PO-Revision-Date: 2021-07-16 10:15+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model,name:hr_applicant_duplicate.model_hr_applicant | ||
msgid "Applicant" | ||
msgstr "" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0 | ||
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0 | ||
#, python-format | ||
msgid "Applicant duplicated or discarded." | ||
msgstr "" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model.fields,field_description:hr_applicant_duplicate.field_hr_applicant__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model.fields,field_description:hr_applicant_duplicate.field_hr_applicant__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: hr_applicant_duplicate | ||
#: model:ir.model.fields,field_description:hr_applicant_duplicate.field_hr_applicant____last_update | ||
msgid "Last Modified on" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import hr_applicant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2021 Berezi - Iker - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models, api, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class HrApplicant(models.Model): | ||
_inherit = 'hr.applicant' | ||
|
||
@api.onchange('partner_mobile', 'email_from') | ||
def onchange_applicant_duplicate(self): | ||
if self.partner_mobile: | ||
cond1 = [ | ||
('partner_mobile', '=', self.partner_mobile), | ||
('active', '=', True)] | ||
cond2 = [ | ||
('partner_mobile', '=', self.partner_mobile), | ||
('active', '=', False)] | ||
employee1 = self.env['hr.applicant'].search(cond1, limit=1) | ||
employee2 = self.env['hr.applicant'].search(cond2, limit=1) | ||
if employee1 or employee2: | ||
raise ValidationError( | ||
_("Applicant duplicated or discarded.")) | ||
if self.email_from: | ||
cond3 = [ | ||
('email_from', '=', self.email_from), ('active', '=', True)] | ||
cond4 = [ | ||
('email_from', '=', self.email_from), ('active', '=', False)] | ||
employee3 = self.env['hr.applicant'].search(cond3, limit=1) | ||
employee4 = self.env['hr.applicant'].search(cond4, limit=1) | ||
if employee3 or employee4: | ||
raise ValidationError( | ||
_("Applicant duplicated or discarded.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_hr_applicant_duplicate |
27 changes: 27 additions & 0 deletions
27
hr_applicant_duplicate/tests/test_hr_applicant_duplicate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2021 Berezi Amubieta - Avanzosc S.L. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests import common | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class TestHrApplicantDuplicate(common.SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestHrApplicantDuplicate, cls).setUpClass() | ||
applicant_obj = cls.env['hr.applicant'] | ||
cls.applicant1 = applicant_obj.create({ | ||
'name': 'aaaa', | ||
'partner_mobile': '11111', | ||
'active': True, | ||
}) | ||
cls.applicant2 = applicant_obj.create({ | ||
'name': 'bbbb', | ||
'email_from': '[email protected]', | ||
'active': False, | ||
}) | ||
|
||
def test_sale_student_event(self): | ||
self.applicant1.email_from = self.applicant2.email_from | ||
with self.assertRaises(ValidationError): | ||
self.applicant1.onchange_applicant_duplicate() |