Skip to content

Commit

Permalink
[ADD] egd_ipva_date_expiry: add new module
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthwhy committed Mar 13, 2024
1 parent de16075 commit 3392309
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 0 deletions.
85 changes: 85 additions & 0 deletions egd_ipva_date_expiry/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
====================
Egd Ipva Date 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 monitor IPVA due dates

**Table of contents**

.. contents::
:local:



Usage
=====


To use this module you need:

1 - In the vehicle registration, enter an expiration date for the IPVA

2 - Enter the ipva expiry menu and expiries close to 1 month will appear

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_ipva_date_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_ipva_date_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 Ipva Date Expiry",
"summary": """
Module monitor IPVA 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_ipva_date_expiry/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import fleet_vehicle
28 changes: 28 additions & 0 deletions egd_ipva_date_expiry/models/fleet_vehicle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 api, fields, models


class FleetVehicle(models.Model):

_inherit = "fleet.vehicle"

ipva_expiry_date = fields.Date(string="IPVA Expiry Date", store="True")
ipva_near_expiry = fields.Boolean(
string="IPVA Near Expiry", compute="_compute_ipva_near_expiry"
)

@api.depends("ipva_expiry_date")
def _compute_ipva_near_expiry(self):
for vehicle in self:
if vehicle.ipva_expiry_date:
expiry_date = fields.Date.from_string(vehicle.ipva_expiry_date)
if expiry_date - datetime.now().date() <= timedelta(days=30):
vehicle.ipva_near_expiry = True
else:
vehicle.ipva_near_expiry = False
else:
vehicle.ipva_near_expiry = False
2 changes: 2 additions & 0 deletions egd_ipva_date_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_ipva_date_expiry/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Module monitor IPVA due dates
4 changes: 4 additions & 0 deletions egd_ipva_date_expiry/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To use this module you need:

1 - In the vehicle registration, enter an expiration date for the IPVA
2 - Enter the ipva expiry menu and expiries close to 1 month will appear
Binary file added egd_ipva_date_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.
58 changes: 58 additions & 0 deletions egd_ipva_date_expiry/views/fleet_vehicle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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_form_view">
<field name="name">fleet.vehicle.form (in egd_ipva_date_expiry)</field>
<field name="model">fleet.vehicle</field>
<field name="inherit_id" ref="fleet.fleet_vehicle_view_form" />
<field name="arch" type="xml">
<field name="vin_sn" position="before">
<field name="ipva_expiry_date" />
</field>
</field>
</record>


<record model="ir.ui.view" id="fleet_vehicle_tree_view">
<field
name="name"
>fleet.vehicle.expiration.tree (in egd_ipva_date_expiry)</field>
<field name="model">fleet.vehicle</field>
<field name="arch" type="xml">
<tree delete="false" create="false" string="Ipva Expiry">
<field name="name" />
<field name="ipva_expiry_date" />
</tree>
</field>
</record>


<record id="action_view_fleet_vehicle_ipva" model="ir.actions.act_window">
<field name="name">IPVA Expiry</field>
<field name="res_model">fleet.vehicle</field>
<field name="view_mode">tree,form</field>
<field
name="domain"
>[('ipva_expiry_date', '&lt;', (context_today() + relativedelta(days=30)).strftime('%Y-%m-%d'))]</field>
<field name="context">{'search_default_ipva_expiry': True}</field>
<field name="help" type="html">
<p
class="o_view_nocontent_smiling_face"
>No vehicles with IPVA expiry within 30 days found.</p>
</field>
</record>



<menuitem
id="menu_fleet_ipva"
name="IPVA Expiry"
parent="fleet.fleet_vehicles"
action="action_view_fleet_vehicle_ipva"
/>



</odoo>
6 changes: 6 additions & 0 deletions setup/egd_ipva_date_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 3392309

Please sign in to comment.