-
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] egd_CNH_expiry: add new module
- Loading branch information
Showing
13 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,80 @@ | ||
============== | ||
Egd CNH Expiry | ||
============== | ||
.. |badge1| 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 | ||
|
||
|badge1| | ||
|
||
Module to track driver's license expiration | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
|
||
1- Access the employee module and set an expiration date for the driver's license | ||
|
||
2 - When the validity is close to one month, | ||
it will appear in a view in fleet/vehicles as cnh expiry | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/Escodoo/{project_repo}/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 | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Escodoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Matheus Marques <[email protected]> | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
The development of this module has been financially supported by: | ||
|
||
* Escodoo - `https://www.escodoo.com.br <https://www.escodoo.com.br>`_ | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the Escodoo. | ||
|
||
.. |maintainer-escodoo| image:: https://github.com/escodoo.png?size=80px | ||
:target: https://github.com/Escodoo | ||
:alt: escodoo | ||
|
||
|maintainer-escodoo| | ||
|
||
We at Escodoo are exclusively dedicated to deploying the Odoo Platform and are | ||
focused on providing solutions that make our customers more competitive, lowering | ||
costs, making technology more accessible and ensuring it is used strategically to | ||
add even more value to the business. | ||
|
||
.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px | ||
:target: https://github.com/marcelsavegnago | ||
:alt: marcelsavegnago | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-marcelsavegnago| | ||
|
||
To contribute to this module, please visit https://www.escodoo.com.br. |
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,14 @@ | ||
# Copyright 2024 - TODAY, Escodoo | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Egd CNH Expiry", | ||
"summary": """ | ||
Module to track driver's license expiration""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Escodoo", | ||
"website": "https://github.com/Escodoo/egd-addons", | ||
"depends": ["l10n_br_hr", "fleet"], | ||
"data": ["views/hr_employee.xml", "views/fleet_vehicle_menu.xml"], | ||
} |
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_employee |
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,45 @@ | ||
# Copyright 2024 - TODAY, Matheus Marques <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from datetime import datetime, timedelta | ||
|
||
from odoo import models | ||
|
||
|
||
class HrEmployee(models.Model): | ||
|
||
_inherit = "hr.employee" | ||
|
||
def _get_employee_expirations(self): | ||
expiration_date_threshold = datetime.now() + timedelta(days=30) | ||
employees = self.env["hr.employee"].search( | ||
[("expiration_date", "<=", expiration_date_threshold)] | ||
) | ||
expirations = [] | ||
for employee in employees: | ||
days_until_expiration = ( | ||
employee.expiration_date - datetime.now().date() | ||
).days | ||
expirations.append( | ||
{"name": employee.name, "days_until_expiration": days_until_expiration} | ||
) | ||
return expirations | ||
|
||
def action_view_employee_expirations(self): | ||
expirations = self._get_employee_expirations() | ||
return { | ||
"name": "Employees with Expiration Date Approaching", | ||
"view_mode": "tree", | ||
"res_model": "employee.expiration", | ||
"type": "ir.actions.act_window", | ||
"context": {"create": False}, | ||
"domain": [], | ||
"view_id": False, | ||
"views": [(False, "tree")], | ||
"target": "current", | ||
"readonly": True, | ||
"limit": 80, | ||
"auto_search": False, | ||
"auto_refresh": 1, | ||
"expirations": expirations, | ||
} |
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,2 @@ | ||
Marcel Savegnago <[email protected]> | ||
Matheus Marques <[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 @@ | ||
Module to track driver's license expiration |
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,5 @@ | ||
To use this module you need: | ||
|
||
1- Access the employee module and set an expiration date for the driver's license | ||
2 - When the validity is close to one month, | ||
it will appear in a view in fleet/vehicles as cnh expiry |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
<!-- Copyright 2024 - TODAY, Matheus Marques <[email protected]> | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<menuitem | ||
id="menu_fleet_employee_expiration" | ||
name="CNH Expiry" | ||
parent="fleet.fleet_vehicles" | ||
sequence="10" | ||
action="action_employee_expiration" | ||
/> | ||
|
||
</odoo> |
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,23 @@ | ||
<odoo> | ||
<record id="view_employee_expiration_tree" model="ir.ui.view"> | ||
<field name="name">hr.employee.expiration.tree (in egd_CNH_expiry)</field> | ||
<field name="model">hr.employee</field> | ||
<field name="arch" type="xml"> | ||
<tree string="CNH Expiry"> | ||
<field name="name" /> | ||
<field name="expiration_date" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="action_employee_expiration" model="ir.actions.act_window"> | ||
<field name="name">CNH Expiry</field> | ||
<field name="res_model">hr.employee</field> | ||
<field name="view_mode">tree</field> | ||
<field name="domain">[('expiration_date', '<=', (context_today() + | ||
relativedelta(days=30)).strftime('%Y-%m-%d')), ('expiration_date', '>=', | ||
context_today().strftime('%Y-%m-%d'))]</field> | ||
</record> | ||
|
||
|
||
</odoo> |
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 @@ | ||
../../../../egd_CNH_expiry |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |