-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] hr_recruitment_job_share: new module
- Loading branch information
Showing
19 changed files
with
740 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,68 @@ | ||
======================== | ||
Hr Recruitment Job Share | ||
======================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:f65466fa3db1bf38827a26dc5413e069b9dfd9a720389cabcabe608918cae583 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-KMEE%2Fkmee--odoo--addons-lightgray.png?logo=github | ||
:target: https://github.com/KMEE/kmee-odoo-addons/tree/16.0/hr_recruitment_job_share | ||
:alt: KMEE/kmee-odoo-addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
It allows the user to share details of a job that has not been published | ||
on the site yet | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Access the work record, click "Share" and copy the link | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/KMEE/kmee-odoo-addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/KMEE/kmee-odoo-addons/issues/new?body=module:%20hr_recruitment_job_share%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* KMEE | ||
|
||
Contributors | ||
------------ | ||
|
||
- ``KMEE <https://www.kmee.com.br>``\ \_: | ||
|
||
- Bruno Corredato Botti | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is part of the `KMEE/kmee-odoo-addons <https://github.com/KMEE/kmee-odoo-addons/tree/16.0/hr_recruitment_job_share>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
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,3 @@ | ||
from . import controllers | ||
from . import models | ||
from . import wizards |
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,21 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Hr Recruitment Job Share", | ||
"summary": """ | ||
Share job in odoo portal""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "KMEE,Odoo Community Association (OCA)", | ||
"website": "https://github.com/KMEE/kmee-odoo-addons", | ||
"depends": [ | ||
"website_hr_recruitment", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/hr_job.xml", | ||
"wizards/job_share.xml", | ||
], | ||
"demo": [], | ||
} |
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 controllers |
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,103 @@ | ||
from odoo import http | ||
from odoo.http import request | ||
from odoo.osv.expression import OR | ||
from odoo.tools.translate import _ | ||
|
||
|
||
class JobShareController(http.Controller): | ||
@http.route( | ||
["/jobs", "/jobs/page/<int:page>"], | ||
type="http", | ||
auth="public", | ||
website=True, | ||
) | ||
def list_jobs( | ||
self, | ||
page=1, | ||
date_begin=None, | ||
date_end=None, | ||
sortby=None, | ||
search=None, | ||
search_in="name", | ||
**kw | ||
): | ||
domain = [] | ||
|
||
searchbar_sortings = { | ||
"date": {"label": _("Newest"), "order": "create_date desc"}, | ||
"name": {"label": _("Name"), "order": "name"}, | ||
} | ||
|
||
searchbar_inputs = { | ||
"name": { | ||
"input": "name", | ||
"label": _('Search <span class="nolabel"> (in Name)</span>'), | ||
}, | ||
"all": {"input": "all", "label": _("Search in All")}, | ||
} | ||
|
||
if not sortby: | ||
sortby = "date" | ||
order = searchbar_sortings[sortby]["order"] | ||
|
||
if date_begin and date_end: | ||
domain += [ | ||
("create_date", ">", date_begin), | ||
("create_date", "<=", date_end), | ||
] | ||
|
||
if search and search_in: | ||
search_domain = [] | ||
if search_in in ("name", "all"): | ||
search_domain = OR([search_domain, [("name", "ilike", search)]]) | ||
domain += search_domain | ||
|
||
hr_job_count = request.env["hr.job"].search_count(domain) | ||
items_per_page = 10 | ||
pager = request.website.pager( | ||
url="/jobs", | ||
total=hr_job_count, | ||
page=page, | ||
step=items_per_page, | ||
) | ||
|
||
hr_jobs = request.env["hr.job"].search( | ||
domain, order=order, limit=items_per_page, offset=pager["offset"] | ||
) | ||
|
||
values = { | ||
"date": date_begin, | ||
"hr_jobs": hr_jobs, | ||
"pager": pager, | ||
"searchbar_sortings": searchbar_sortings, | ||
"searchbar_inputs": searchbar_inputs, | ||
"sortby": sortby, | ||
"search_in": search_in, | ||
"search": search, | ||
} | ||
|
||
return request.render("website_hr_recruitment.detail", values) | ||
|
||
@http.route( | ||
["/jobs/details/<int:hr_job_id>"], type="http", auth="public", website=True | ||
) | ||
def job_followup(self, hr_job_id=None, access_token=None, **kw): | ||
|
||
hr_job_sudo = ( | ||
request.env["hr.job"].sudo().search([("id", "=", hr_job_id)], limit=1) | ||
) | ||
|
||
values = {"page_name": "hr_job", "job": hr_job_sudo} | ||
return request.render("website_hr_recruitment.detail", values) | ||
|
||
@http.route( | ||
["/jobs/apply/<int:hr_job_id>"], type="http", auth="public", website=True | ||
) | ||
def job_apply(self, hr_job_id=None, **kw): | ||
|
||
hr_job_sudo = ( | ||
request.env["hr.job"].sudo().search([("id", "=", hr_job_id)], limit=1) | ||
) | ||
|
||
values = {"job": hr_job_sudo} | ||
return request.render("website_hr_recruitment.apply", values) |
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_job |
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,48 @@ | ||
import secrets | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class Job(models.Model): | ||
_inherit = "hr.job" | ||
|
||
access_token = fields.Char( | ||
"Token de Acesso", copy=False, default=lambda self: secrets.token_urlsafe(16) | ||
) | ||
is_shared = fields.Boolean("É compartilhado?", default=False) | ||
application_url = fields.Char("URL da Vaga", compute="_compute_application_url") | ||
|
||
def get_share_url(self): | ||
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url") | ||
return f"{base_url}/jobs/details/{self.id}?access_token={self.access_token}" | ||
|
||
@api.depends("access_token") | ||
def _compute_application_url(self): | ||
for job in self: | ||
job.application_url = job.get_share_url() if job.access_token else "" | ||
|
||
def action_share_job(self): | ||
self.ensure_one() | ||
# Gerar um novo token ao compartilhar o trabalho | ||
self.access_token = secrets.token_urlsafe(16) # Garante que cada token é único | ||
self.is_shared = True | ||
return { | ||
"type": "ir.actions.act_window", | ||
"res_model": "job.share.wizard", | ||
"view_mode": "form", | ||
"target": "new", | ||
"context": {"default_job_id": self.id}, | ||
} | ||
|
||
@api.model | ||
def create(self, vals): | ||
# Garante que o token de acesso é gerado no momento da criação | ||
if "access_token" not in vals: | ||
vals["access_token"] = secrets.token_urlsafe(16) | ||
return super(Job, self).create(vals) | ||
|
||
def write(self, vals): | ||
# Se o trabalho não estiver sendo compartilhado, não altere o token | ||
if "is_shared" in vals and vals["is_shared"]: | ||
self.access_token = secrets.token_urlsafe(16) | ||
return super(Job, self).write(vals) |
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,3 @@ | ||
* `KMEE <https://www.kmee.com.br>`_: | ||
|
||
* Bruno Corredato Botti |
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 @@ | ||
It allows the user to share details of a job that has not been published on the site yet |
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 @@ | ||
Access the work record, click "Share" and copy the link |
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,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_job_share_wizard,job.share.wizard,model_job_share_wizard,hr_recruitment.group_hr_recruitment_user,1,1,1,1 | ||
access_hr_job_public,access_hr_job_public,model_hr_job,base.group_public,1,0,0,0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.