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] (Web) HR Labels #7

Open
wants to merge 5 commits into
base: 16.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
1 change: 1 addition & 0 deletions hr_recruitment_label/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
24 changes: 24 additions & 0 deletions hr_recruitment_label/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2017-2023 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "HR Recruitment labels",
"summary": "Add's labels on job offers",
"author": "Onestein",
"website": "https://www.onestein.nl",
"category": "Human Resources/Recruitment",
"version": "16.0.1.0.7",
"license": "AGPL-3",
"depends": [
"hr_recruitment",
],
"demo": [
"data/hr_recruitment_label_demo.xml",
],
"data": [
"security/ir.model.access.csv",
"views/hr_job_label_category_views.xml",
"views/hr_job_label_views.xml",
"views/hr_job_views.xml",
],
}
77 changes: 77 additions & 0 deletions hr_recruitment_label/data/hr_recruitment_label_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<odoo noupdate="1">
<record id="categ1" model="hr.job.label.category">

<field name="name">Category 1</field>
<field name="color">1</field>
<field name="sequence">1</field>
</record>
<record id="categ2" model="hr.job.label.category">
<field name="name">Category 2</field>
<field name="color">2</field>
<field name="sequence">2</field>
</record>
<record id="categ3" model="hr.job.label.category">
<field name="name">Category 3</field>
<field name="color">3</field>
<field name="sequence">3</field>
</record>
<record id="label1_cat1" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ1" />
<field name="name">Label 1</field>
<field name="sequence">1</field>
</record>
<record id="label2_cat1" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ1" />
<field name="name">Label 2</field>
<field name="sequence">2</field>
</record>
<record id="label3_cat1" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ1" />
<field name="name">Label 3</field>
<field name="sequence">3</field>
</record>
<record id="label1_cat2" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ2" />
<field name="name">Option 1</field>
<field name="sequence">4</field>
</record>
<record id="label2_cat2" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ2" />
<field name="name">Option 2</field>
<field name="sequence">5</field>
</record>
<record id="label1_cat3" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ3" />
<field name="name">Value 1</field>
<field name="sequence">6</field>
</record>
<record id="label2_cat3" model="hr.job.label">
<field name="category_id" ref="hr_recruitment_label.categ3" />
<field name="name">Value 2</field>
<field name="sequence">7</field>
</record>

<!--Manage the job_id to get in hr.applicant-->
<record id="hr.job_developer" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label1_cat1'),ref('label1_cat2'),ref('label1_cat3')])]" />
</record>
<record id="hr.job_ceo" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label2_cat1'),ref('label1_cat2'),ref('label2_cat3')])]" />
</record>
<record id="hr.job_cto" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label3_cat1'),ref('label1_cat2'),ref('label1_cat3')])]" />
</record>
<record id="hr.job_consultant" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label1_cat1'),ref('label2_cat2'),ref('label2_cat3')])]" />
</record>
<record id="hr.job_hrm" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label2_cat1'),ref('label2_cat2'),ref('label1_cat3')])]" />
</record>
<record id="hr.job_marketing" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label3_cat1'),ref('label2_cat2'),ref('label2_cat3')])]" />
</record>
<record id="hr.job_trainee" model="hr.job">
<field name="label_ids" eval="[(6, 0, [ref('label2_cat1'),ref('label2_cat2'),ref('label1_cat3')])]" />
</record>
</odoo>
3 changes: 3 additions & 0 deletions hr_recruitment_label/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import hr_job
from . import hr_job_label
from . import hr_job_label_category
10 changes: 10 additions & 0 deletions hr_recruitment_label/models/hr_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2017-2023 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class HrJob(models.Model):
_inherit = "hr.job"

label_ids = fields.Many2many(comodel_name="hr.job.label")
33 changes: 33 additions & 0 deletions hr_recruitment_label/models/hr_job_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2017-2023 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class HrJobLabel(models.Model):
_name = "hr.job.label"
_order = "category_id,sequence"
_rec_name = "rec_name"

rec_name = fields.Char(compute="_compute_rec_name", store=True)

sequence = fields.Integer()
category_id = fields.Many2one(comodel_name="hr.job.label.category", required=1)
name = fields.Char(translate=True, required=1)
color = fields.Integer(related="category_id.color")

@api.depends("category_id", "category_id.name", "name")
def _compute_rec_name(self):
for label in self:
label.rec_name = "%(categ_name)s: %(label_name)s" % {

Check warning on line 22 in hr_recruitment_label/models/hr_job_label.py

View check run for this annotation

Codecov / codecov/patch

hr_recruitment_label/models/hr_job_label.py#L22

Added line #L22 was not covered by tests
"categ_name": label.category_id.name,
"label_name": label.name,
}

_sql_constraints = [
(
"name_uniq",
"unique (name,categ_id)",
"Label name already exists within " "this category!",
),
]
12 changes: 12 additions & 0 deletions hr_recruitment_label/models/hr_job_label_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import fields, models


class HrJobCategory(models.Model):
_name = "hr.job.label.category"
_rec_name = "name"
_order = "sequence"

sequence = fields.Integer()
name = fields.Char(translate=True, required=1)
color = fields.Integer()
label_ids = fields.One2many(comodel_name="hr.job.label", inverse_name="category_id")
6 changes: 6 additions & 0 deletions hr_recruitment_label/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_job_label_user,access_hr_job_label_user,hr_recruitment_label.model_hr_job_label,hr.group_hr_user,1,0,0,0
access_hr_job_label_manager,access_hr_job_label_manager,hr_recruitment_label.model_hr_job_label,hr_recruitment.group_hr_recruitment_user,1,1,1,1

access_hr_job_label_category_user,access_hr_job_label_category_user,hr_recruitment_label.model_hr_job_label_category,hr.group_hr_user,1,0,0,0
access_hr_job_label_category_manager,access_hr_job_label_category_manager,hr_recruitment_label.model_hr_job_label_category,hr_recruitment.group_hr_recruitment_user,1,1,1,1
39 changes: 39 additions & 0 deletions hr_recruitment_label/views/hr_job_label_category_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_job_label_category_tree_view" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job_label_category.tree</field>
<field name="model">hr.job.label.category</field>
<field name="arch" type="xml">
<tree editable="top">
<field name="sequence" widget="handle" />
<field name="name" />
<field name="color" widget="color_picker" />
</tree>
</field>
</record>


<record id="hr_job_label_category_search_view" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job_label_category.search</field>
<field name="model">hr.job.label.category</field>
<field name="arch" type="xml">
<search string="Job Labels">
<field name="name" />
</search>
</field>
</record>


<record id="hr_job_label_category_act_window" model="ir.actions.act_window">
<field name="name">Label Categories</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.job.label.category</field>
<field name="view_mode">tree</field>
</record>

<menuitem name="Label Categories"
id="hr_job_label_category_menu"
parent="hr_recruitment.menu_hr_recruitment_config_jobs"
action="hr_job_label_category_act_window" />

</odoo>
43 changes: 43 additions & 0 deletions hr_recruitment_label/views/hr_job_label_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_job_label_tree_view" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job_label.tree</field>
<field name="model">hr.job.label</field>
<field name="arch" type="xml">
<tree editable="top">
<field name="sequence" widget="handle"/>
<field name="category_id"/>
<field name="name"/>
<field name="color" widget="color_picker"/>
</tree>
</field>
</record>


<record id="hr_job_label_search_view" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job_label.search</field>
<field name="model">hr.job.label</field>
<field name="arch" type="xml">
<search string="Job Labels">
<field name="name" filter_domain="[('rec_name','ilike',self)]"/>
<group expand="0" string="Group By">
<filter name="category" string="Category" domain="[]" context="{'group_by': 'category_id'}"/>
</group>
</search>
</field>
</record>


<record id="hr_job_label_act_window" model="ir.actions.act_window">
<field name="name">Labels</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.job.label</field>
<field name="view_mode">tree</field>
</record>

<menuitem name="Labels"
id="hr_job_label_menu"
parent="hr_recruitment.menu_hr_recruitment_config_jobs"
action="hr_job_label_act_window"/>

</odoo>
45 changes: 45 additions & 0 deletions hr_recruitment_label/views/hr_job_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_job_form_inherit" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job.form.inherit</field>
<field name="model">hr.job</field>
<field name="inherit_id" ref="hr.view_hr_job_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='contract_type_id']" position="after">
<field name="label_ids" widget="many2many_tags"
options="{'color_field': 'color'}" />
</xpath>
</field>
</record>
<record id="hr_job_kanban_inherit" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job.kanban.inherit</field>
<field name="model">hr.job</field>
<field name="inherit_id" ref="hr_recruitment.view_hr_job_kanban" />
<field name="arch" type="xml">
<xpath expr="//field[@name='active']" position="after">
<field name="label_ids" />
</xpath>
<xpath expr="//ul/*[last()]" position="after">
<li>
<field name="label_ids"
widget="many2many_tags"
options="{'color_field': 'color'}" />
</li>
</xpath>
</field>
</record>
<record id="hr_job_search_inherit" model="ir.ui.view">
<field name="name">hr_recruitment_label.hr_job.search.inherit</field>
<field name="model">hr.job</field>
<field name="inherit_id" ref="hr.view_job_filter" />
<field name="arch" type="xml">
<xpath expr="//field[@name='department_id']" position="after">
<field name="label_ids" />
</xpath>
<xpath expr="//filter[@name='employment_type']" position="after">
<filter string="Labels" name="label_ids" domain="[]" context="{'group_by': 'label_ids'}" />
</xpath>
</field>
</record>

</odoo>
2 changes: 2 additions & 0 deletions website_hr_recruitment_label/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
27 changes: 27 additions & 0 deletions website_hr_recruitment_label/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2017-2023 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Website HR recruitment labels",
"summary": "Adds the option to filter/display job labels on the website",
"author": "Onestein",
"website": "https://www.onestein.nl",
"category": "Human Resources/Recruitment",
"version": "16.0.1.0.16",
"license": "AGPL-3",
"depends": ["hr_recruitment_label", "website_hr_recruitment"],
"data": [
"views/hr_job_label_category_views.xml",
"views/website_hr_recruitment_label_templates.xml",
"views/snippets.xml",
],
"demo": [
"data/web_hr_recruitment_label.xml",
],
"assets": {
"web.assets_frontend": [
"/website_hr_recruitment_label/static/src/js/job_filter.js",
"/website_hr_recruitment_label/static/src/css/style.css",
]
},
}
1 change: 1 addition & 0 deletions website_hr_recruitment_label/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
Loading
Loading