Skip to content

Commit

Permalink
[ADD] egd_national_registration_expiry: add new module
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthwhy committed Mar 20, 2024
1 parent 93f91a3 commit 546d8ff
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 0 deletions.
81 changes: 81 additions & 0 deletions egd_national_registration_expiry/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
================================
Egd National Registration 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 creates reinava fields in the fleet, and monitors due dates

**Table of contents**

.. contents::
:local:

Configuration
=============

To Configure...

Usage
=====

To usage...

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]>

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_national_registration_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_national_registration_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 National Registration Expiry",
"summary": """
Module creates reinava fields in the fleet, and monitors due dates""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Escodoo",
"website": "https://github.com/Escodoo/egd-addons",
"depends": ["fleet"],
"data": ["views/fleet_vehicle.xml"],
}
1 change: 1 addition & 0 deletions egd_national_registration_expiry/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import fleet_vehicle
26 changes: 26 additions & 0 deletions egd_national_registration_expiry/models/fleet_vehicle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 - TODAY, Matheus Marques <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from datetime import datetime, timedelta


class FleetVehicle(models.Model):

_inherit = "fleet.vehicle"

renavam_number = fields.Char(string='Renavam number')
renavam_validity = fields.Date(string='Renavam expiry')
renavam_near_expiry = fields.Boolean(string='renavam Near Expiry', compute='_compute_renavam_near_expiry')

@api.depends('renavam_validity')
def _compute_renavam_near_expiry(self):
for vehicle in self:
if vehicle.renavam_validity:
expiry_date = fields.Date.from_string(vehicle.renavam_validity)
if expiry_date - datetime.now().date() <= timedelta(days=30):
vehicle.renavam_near_expiry = True
else:
vehicle.renavam_near_expiry = False
else:
vehicle.renavam_near_expiry = False
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions egd_national_registration_expiry/views/fleet_vehicle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 - TODAY, Matheus Marques <[email protected]>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="fleet_vehicle_view_form_inherit">
<field
name="name"
>fleet.vehicle.inherit.registration (in egd_national_registration_expiry)</field>
<field name="model">fleet.vehicle</field>
<field name="inherit_id" ref="fleet.fleet_vehicle_view_form" />
<field name="arch" type="xml">
<xpath expr="//group[(@name='contract')]" position="after">
<group>
<group string="Renavam">
<field name="renavam_number" />
<field name="renavam_validity" />
</group>
</group>
</xpath>
</field>
</record>


<record id="view_fleet_vehicle_registration_tree" model="ir.ui.view">
<field
name="name"
>fleet.vehicle.registration.tree (in egd_national_registration_expiry)</field>
<field name="model">fleet.vehicle</field>
<field name="arch" type="xml">
<tree string="Renavam expiry">
<field name="name" />
<field name="renavam_validity" />
</tree>
</field>
</record>

<record id="action_fleet_vehicle_renewal_list" model="ir.actions.act_window">
<field name="name">Renavam expiry</field>
<field name="res_model">fleet.vehicle</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_fleet_vehicle_registration_tree" />
<field
name="domain"
>[('renavam_validity', '&lt;', (context_today() + relativedelta(days=30)).strftime('%Y-%m-%d'))]</field>
<field name="context">{'search_default_renavam_validity': True}</field>
</record>

<menuitem
id="menu_fleet_vehicle_renewal_list"
name="Renavam expiry"
parent="fleet.fleet_vehicles"
action="action_fleet_vehicle_renewal_list"
/>


</odoo>
6 changes: 6 additions & 0 deletions setup/egd_national_registration_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 546d8ff

Please sign in to comment.