diff --git a/egd_ipva_date_expiry/README.rst b/egd_ipva_date_expiry/README.rst index 17bec36..a2110fd 100644 --- a/egd_ipva_date_expiry/README.rst +++ b/egd_ipva_date_expiry/README.rst @@ -1,11 +1,26 @@ ==================== Egd Ipva Date Expiry ==================== -.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e2ab2a3df8a5165e39df984c429792a78cdbbb98dfd0d8e6eaaa585c827aa8f0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-Escodoo%2Fegd--addons-lightgray.png?logo=github + :target: https://github.com/Escodoo/egd-addons/tree/14.0/egd_ipva_date_expiry + :alt: Escodoo/egd-addons -|badge1| +|badge1| |badge2| |badge3| Module monitor IPVA due dates @@ -14,25 +29,22 @@ Module monitor IPVA due dates .. 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 +2 - In fleet vehicles tree view, you will have the fields related to IPVA expiration +and filters to search vehicles with IPVA expired, expiring soon or valid. Bug Tracker =========== -Bugs are tracked on `GitHub 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. +Bugs are tracked on `GitHub 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 `_. Do not contact contributors directly about support or help with technical issues. @@ -47,39 +59,15 @@ Authors Contributors ~~~~~~~~~~~~ -* Marcel Savegnago - -* Matheus Marques - -Other credits -~~~~~~~~~~~~~ +* `Escodoo `_: -The development of this module has been financially supported by: - -* Escodoo - `https://www.escodoo.com.br `_ + * Marcel Savegnago + * Matheus Marques + * Wesley Oliveira 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 `__: - -|maintainer-marcelsavegnago| +This module is part of the `Escodoo/egd-addons `_ project on GitHub. -To contribute to this module, please visit https://www.escodoo.com.br. +You are welcome to contribute. diff --git a/egd_ipva_date_expiry/i18n/pt_BR.po b/egd_ipva_date_expiry/i18n/pt_BR.po new file mode 100644 index 0000000..3630935 --- /dev/null +++ b/egd_ipva_date_expiry/i18n/pt_BR.po @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * egd_ipva_date_expiry +# +# Translators: +# Wesley Oliveira , 2024 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-08 19:15+0000\n" +"PO-Revision-Date: 2024-10-08 19:15+0000\n" +"Last-Translator: Wesley Oliveira, 2024" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields,field_description:egd_ipva_date_expiry.field_fleet_vehicle__display_name +msgid "Display Name" +msgstr "Nome exibido" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields.selection,name:egd_ipva_date_expiry.selection__fleet_vehicle__ipva_expiry_state__expired +msgid "Expired" +msgstr "Expirado" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields.selection,name:egd_ipva_date_expiry.selection__fleet_vehicle__ipva_expiry_state__expiring_soon +msgid "Expiring Soon" +msgstr "Expira em breve" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields,field_description:egd_ipva_date_expiry.field_fleet_vehicle__id +msgid "ID" +msgstr "ID" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields,field_description:egd_ipva_date_expiry.field_fleet_vehicle__ipva_days_to_expire +msgid "IPVA Days to Expire" +msgstr "Dias para Expirar IPVA" + +#. module: egd_ipva_date_expiry +#: model_terms:ir.ui.view,arch_db:egd_ipva_date_expiry.fleet_vehicle_view_search +msgid "IPVA Expired" +msgstr "IPVA Expirado" + +#. module: egd_ipva_date_expiry +#: model_terms:ir.ui.view,arch_db:egd_ipva_date_expiry.fleet_vehicle_view_search +msgid "IPVA Expiring Soon" +msgstr "IPVA Expira em Breve" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields,field_description:egd_ipva_date_expiry.field_fleet_vehicle__ipva_expiry_date +msgid "IPVA Expiry Date" +msgstr "Data de Expiração IPVA" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields,field_description:egd_ipva_date_expiry.field_fleet_vehicle__ipva_expiry_state +msgid "IPVA Expiry State" +msgstr "Status de Expiração IPVA" + +#. module: egd_ipva_date_expiry +#: model_terms:ir.ui.view,arch_db:egd_ipva_date_expiry.fleet_vehicle_view_search +msgid "IPVA Valid" +msgstr "IPVA Válido" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields,field_description:egd_ipva_date_expiry.field_fleet_vehicle____last_update +msgid "Last Modified on" +msgstr "Última modificação em" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields.selection,name:egd_ipva_date_expiry.selection__fleet_vehicle__ipva_expiry_state__no_ipva +msgid "No IPVA" +msgstr "Sem IPVA" + +#. module: egd_ipva_date_expiry +#: model:ir.model.fields.selection,name:egd_ipva_date_expiry.selection__fleet_vehicle__ipva_expiry_state__valid +msgid "Valid" +msgstr "Válido" + +#. module: egd_ipva_date_expiry +#: model:ir.model,name:egd_ipva_date_expiry.model_fleet_vehicle +msgid "Vehicle" +msgstr "Veículo" diff --git a/egd_ipva_date_expiry/models/fleet_vehicle.py b/egd_ipva_date_expiry/models/fleet_vehicle.py index daddc66..8567e15 100644 --- a/egd_ipva_date_expiry/models/fleet_vehicle.py +++ b/egd_ipva_date_expiry/models/fleet_vehicle.py @@ -1,7 +1,8 @@ # Copyright 2024 - TODAY, Matheus Marques +# Copyright 2024 - TODAY, Wesley Oliveira # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from datetime import datetime, timedelta +from datetime import date from odoo import api, fields, models @@ -11,18 +12,44 @@ 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" + ipva_days_to_expire = fields.Integer( + string="IPVA Days to Expire", + compute="_compute_ipva_days_to_expire", + readonly=True, + ) + ipva_expiry_state = fields.Selection( + selection=[ + ("valid", "Valid"), + ("expiring_soon", "Expiring Soon"), + ("expired", "Expired"), + ("no_ipva", "No IPVA"), + ], + string="IPVA Expiry State", + compute="_compute_ipva_expiry_state", + store=True, + readonly=True, ) @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 + def _compute_ipva_days_to_expire(self): + today = date.today() + for fleet in self: + if fleet.ipva_expiry_date: + days = (fleet.ipva_expiry_date - today).days + fleet.ipva_days_to_expire = days else: - vehicle.ipva_near_expiry = False + fleet.ipva_days_to_expire = 0 + fleet._compute_ipva_expiry_state() + + @api.depends("ipva_expiry_date", "ipva_days_to_expire") + def _compute_ipva_expiry_state(self): + for fleet in self: + if not fleet.ipva_expiry_date: + fleet.ipva_expiry_state = "no_ipva" + else: + if fleet.ipva_days_to_expire < 0: + fleet.ipva_expiry_state = "expired" + elif fleet.ipva_days_to_expire <= 30: + fleet.ipva_expiry_state = "expiring_soon" + else: + fleet.ipva_expiry_state = "valid" diff --git a/egd_ipva_date_expiry/readme/CONTRIBUTORS.rst b/egd_ipva_date_expiry/readme/CONTRIBUTORS.rst index d019575..94ec8c1 100644 --- a/egd_ipva_date_expiry/readme/CONTRIBUTORS.rst +++ b/egd_ipva_date_expiry/readme/CONTRIBUTORS.rst @@ -1,2 +1,5 @@ -Marcel Savegnago -Matheus Marques +* `Escodoo `_: + + * Marcel Savegnago + * Matheus Marques + * Wesley Oliveira diff --git a/egd_ipva_date_expiry/readme/USAGE.rst b/egd_ipva_date_expiry/readme/USAGE.rst index 9136b3d..c5a997b 100644 --- a/egd_ipva_date_expiry/readme/USAGE.rst +++ b/egd_ipva_date_expiry/readme/USAGE.rst @@ -1,4 +1,5 @@ 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 +2 - In fleet vehicles tree view, you will have the fields related to IPVA expiration +and filters to search vehicles with IPVA expired, expiring soon or valid. diff --git a/egd_ipva_date_expiry/static/description/index.html b/egd_ipva_date_expiry/static/description/index.html new file mode 100644 index 0000000..01f97ac --- /dev/null +++ b/egd_ipva_date_expiry/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +Egd Ipva Date Expiry + + + +
+

Egd Ipva Date Expiry

+ + +

Beta License: AGPL-3 Escodoo/egd-addons

+

Module monitor IPVA due dates

+

Table of contents

+ +
+

Usage

+

To use this module you need:

+

1 - In the vehicle registration, enter an expiration date for the IPVA +2 - In fleet vehicles tree view, you will have the fields related to IPVA expiration +and filters to search vehicles with IPVA expired, expiring soon or valid.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the Escodoo/egd-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/egd_ipva_date_expiry/views/fleet_vehicle.xml b/egd_ipva_date_expiry/views/fleet_vehicle.xml index 48ec8ac..cb83f5d 100644 --- a/egd_ipva_date_expiry/views/fleet_vehicle.xml +++ b/egd_ipva_date_expiry/views/fleet_vehicle.xml @@ -1,6 +1,9 @@ - + @@ -14,39 +17,50 @@ - - fleet.vehicle.tree.ipva.expiry (in egd_ipva_date_expiry) + + fleet.vehicle.tree (in egd_ipva_date_expiry) fleet.vehicle + - - - - + + + + + - - IPVA Expiry - fleet.vehicle - tree - - [('ipva_expiry_date', '<', (context_today() + - relativedelta(days=30)).strftime('%Y-%m-%d'))] - {'search_default_ipva_expiry': True} - -

No fleet vehicles with IPVA expiry within 30 - days found.

+ + fleet.vehicle.search (in egd_ipva_date_expiry) + fleet.vehicle + + + + + + + + -