Skip to content

Commit

Permalink
[ADD] egd_CNH_expiry: add new module
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthwhy committed Mar 11, 2024
1 parent e203cd1 commit 0c07179
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 0 deletions.
80 changes: 80 additions & 0 deletions egd_CNH_expiry/README.rst
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.
1 change: 1 addition & 0 deletions egd_CNH_expiry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions egd_CNH_expiry/__manifest__.py
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"],
}
1 change: 1 addition & 0 deletions egd_CNH_expiry/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import hr_employee
45 changes: 45 additions & 0 deletions egd_CNH_expiry/models/hr_employee.py
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,
}
2 changes: 2 additions & 0 deletions egd_CNH_expiry/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Marcel Savegnago <[email protected]>
Matheus Marques <[email protected]>
1 change: 1 addition & 0 deletions egd_CNH_expiry/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Module to track driver's license expiration
5 changes: 5 additions & 0 deletions egd_CNH_expiry/readme/USAGE.rst
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
Binary file added egd_CNH_expiry/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions egd_CNH_expiry/views/fleet_vehicle_menu.xml
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>
23 changes: 23 additions & 0 deletions egd_CNH_expiry/views/hr_employee.xml
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', '&lt;=', (context_today() +
relativedelta(days=30)).strftime('%Y-%m-%d')), ('expiration_date', '>=',
context_today().strftime('%Y-%m-%d'))]</field>
</record>


</odoo>
1 change: 1 addition & 0 deletions setup/egd_CNH_expiry/odoo/addons/egd_CNH_expiry
6 changes: 6 additions & 0 deletions setup/egd_CNH_expiry/setup.py
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,
)

0 comments on commit 0c07179

Please sign in to comment.