Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] hr_applicant_duplicate: Onchange in phone and email to see if t… #100

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
cache: pip

python:
- "3.5"
- "3.6"

addons:
postgresql: "9.6"
Expand Down
28 changes: 28 additions & 0 deletions hr_applicant_duplicate/README.rst
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]>
1 change: 1 addition & 0 deletions hr_applicant_duplicate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions hr_applicant_duplicate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Berezi - 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",
"website": "https://www.avanzosc.es",
"category": "Sales",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"website": "https://www.avanzosc.es",

"depends": [
"hr_recruitment",
],
"data": [
],
"license": "AGPL-3",
'installable': True,
}
54 changes: 54 additions & 0 deletions hr_applicant_duplicate/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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-21 11:50+0000\n"
"PO-Revision-Date: 2021-07-21 11:50+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
#, python-format
msgid "Applicant email is duplicated."
msgstr "El correo del candidato es duplicado."

#. module: hr_applicant_duplicate
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0
#, python-format
msgid "Applicant mobile is duplicated."
msgstr "El móvil del cancidato es duplicado."

#. module: hr_applicant_duplicate
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0
#, python-format
msgid "Applicant phone is duplicated."
msgstr "El teléfono del candidato es duplicado."

#. 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"
54 changes: 54 additions & 0 deletions hr_applicant_duplicate/i18n/hr_applicant_duplicate.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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-21 11:50+0000\n"
"PO-Revision-Date: 2021-07-21 11:50+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
#, python-format
msgid "Applicant email is duplicated."
msgstr ""

#. module: hr_applicant_duplicate
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0
#, python-format
msgid "Applicant mobile is duplicated."
msgstr ""

#. module: hr_applicant_duplicate
#: code:addons/hr_applicant_duplicate/models/hr_applicant.py:0
#, python-format
msgid "Applicant phone is duplicated."
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 ""
1 change: 1 addition & 0 deletions hr_applicant_duplicate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import hr_applicant
38 changes: 38 additions & 0 deletions hr_applicant_duplicate/models/hr_applicant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2021 Berezi - 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.constrains('partner_mobile', 'partner_phone', 'email_from')
def _check_applicant_duplicate(self):
for applicant in self:
if applicant.partner_mobile:
cond = [('id', '!=', applicant.id), '|',
('partner_mobile', 'ilike', applicant.partner_mobile),
('partner_phone', 'ilike', applicant.partner_mobile),
'|', ('active', '=', True), ('active', '=', False)]
employee = applicant.env['hr.applicant'].search(cond, limit=1)
if employee and employee != applicant.id:
raise ValidationError(
_("Applicant mobile is duplicated."))
if applicant.partner_phone:
cond = [('id', '!=', applicant.id), '|',
('partner_phone', 'ilike', applicant.partner_phone),
('partner_mobile', 'ilike', applicant.partner_phone),
'|', ('active', '=', True), ('active', '=', False)]
employee = applicant.env['hr.applicant'].search(cond, limit=1)
if employee:
raise ValidationError(
_("Applicant phone is duplicated."))
if applicant.email_from:
cond = [('id', '!=', applicant.id),
('email_from', '=ilike', applicant.email_from), '|',
('active', '=', True), ('active', '=', False)]
employee = applicant.env['hr.applicant'].search(cond, limit=1)
if employee:
raise ValidationError(
_("Applicant email is duplicated."))
1 change: 1 addition & 0 deletions hr_applicant_duplicate/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_hr_applicant_duplicate
31 changes: 31 additions & 0 deletions hr_applicant_duplicate/tests/test_hr_applicant_duplicate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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',
'partner_phone': '22222',
'active': True,
})
cls.applicant2 = applicant_obj.create({
'name': 'bbbb',
'email_from': '[email protected]',
'active': False,
})

def test_hr_applicant_duplicate(self):
with self.assertRaises(ValidationError):
self.applicant1.email_from = self.applicant2.email_from
with self.assertRaises(ValidationError):
self.applicant2.partner_mobile = self.applicant1.partner_mobile
with self.assertRaises(ValidationError):
self.applicant2.partner_phone = self.applicant1.partner_phone