Skip to content

Commit

Permalink
[15.0][IMP] fleet_vehicle_inspection: Add cost vehicle inspection and…
Browse files Browse the repository at this point in the history
… create vehicle service
  • Loading branch information
carolinafernandez-tecnativa committed Dec 14, 2023
1 parent c1fd1af commit 3a0d84b
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 3 deletions.
4 changes: 3 additions & 1 deletion fleet_vehicle_inspection/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Fleet Vehicle Inspection
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fce4f2a5a75b3e85a51c0573831ea5e4c6511dc7afad3fcc4bea8702516f13e8
!! source digest: sha256:e9f054b06950870741c0c7c58018aee2c01a8d15fd0bbc92cfc1051094f77442
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -29,6 +29,7 @@ Fleet Vehicle Inspection
|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the Fleet module allowing the registration of vehicle entry and exit inspections.
Add Cost vehicle inspections. Once is confirmed, service vehicle is created. If inspection is cancelled, service vehicle is deleted.

**Table of contents**

Expand Down Expand Up @@ -72,6 +73,7 @@ Contributors

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
* Brian McMaster <brian@mcmpest.com>
* Tecnativa - Carolina Fernandez

Other credits
~~~~~~~~~~~~~
Expand Down
36 changes: 36 additions & 0 deletions fleet_vehicle_inspection/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ msgstr "Cancelar"
msgid "Canceled"
msgstr "Cancelada"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__company_id
msgid "Company"
msgstr "Compañía"

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Confirm Inspection"
Expand All @@ -125,6 +130,11 @@ msgstr "Confirmar Inspección"
msgid "Confirmed"
msgstr "Confirmada"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__amount
msgid "Cost"
msgstr "Coste"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__create_uid
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__create_uid
Expand All @@ -141,6 +151,11 @@ msgstr "Creado por"
msgid "Created on"
msgstr "Creada en"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__currency_id
msgid "Currency"
msgstr "Moneda"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,help:fleet_vehicle_inspection.field_fleet_vehicle_inspection__date_inspected
msgid "Date when the vehicle has been inspected"
Expand Down Expand Up @@ -502,6 +517,12 @@ msgstr "Mensajes"
msgid "Miles"
msgstr "Millas"

#. module: fleet_vehicle_inspection
#: code:addons/fleet_vehicle_inspection/models/fleet_vehicle_inspection.py:0
#, python-format
msgid "Must select service type"
msgstr "Debe seleccionar el tipo de servicio"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__my_activity_date_deadline
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__my_activity_date_deadline
Expand Down Expand Up @@ -665,6 +686,16 @@ msgstr "Descripción del Resultado"
msgid "Sequence"
msgstr "Secuencia"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_id
msgid "Service"
msgstr "Servicio"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_type_id
msgid "Service Type"
msgstr "Tipo de servicio"

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Set to Draft"
Expand Down Expand Up @@ -772,6 +803,11 @@ msgstr "Mensajes de la Página web"
msgid "Website communication history"
msgstr "Historial de comunicación del sitio web"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__vendor_id
msgid "Vendor"
msgstr "Proveedor"

#~ msgid "SMS Delivery error"
#~ msgstr "Error de entrega de SMS"

Expand Down
36 changes: 36 additions & 0 deletions fleet_vehicle_inspection/i18n/fleet_vehicle_inspection.pot
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ msgstr ""
msgid "Canceled"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__company_id
msgid "Company"
msgstr ""

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Confirm Inspection"
Expand All @@ -115,6 +120,11 @@ msgstr ""
msgid "Confirmed"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__amount
msgid "Cost"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__create_uid
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__create_uid
Expand All @@ -131,6 +141,11 @@ msgstr ""
msgid "Created on"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__currency_id
msgid "Currency"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,help:fleet_vehicle_inspection.field_fleet_vehicle_inspection__date_inspected
msgid "Date when the vehicle has been inspected"
Expand Down Expand Up @@ -492,6 +507,12 @@ msgstr ""
msgid "Miles"
msgstr ""

#. module: fleet_vehicle_inspection
#: code:addons/fleet_vehicle_inspection/models/fleet_vehicle_inspection.py:0
#, python-format
msgid "Must select service type"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__my_activity_date_deadline
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__my_activity_date_deadline
Expand Down Expand Up @@ -652,6 +673,16 @@ msgstr ""
msgid "Sequence"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_id
msgid "Service"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_type_id
msgid "Service Type"
msgstr ""

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Set to Draft"
Expand Down Expand Up @@ -754,3 +785,8 @@ msgstr ""
#: model:ir.model.fields,help:fleet_vehicle_inspection.field_fleet_vehicle_inspection_line__website_message_ids
msgid "Website communication history"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__vendor_id
msgid "Vendor"
msgstr ""
36 changes: 36 additions & 0 deletions fleet_vehicle_inspection/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ msgstr "Annulla"
msgid "Canceled"
msgstr "Annullata"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__company_id
msgid "Company"
msgstr ""

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Confirm Inspection"
Expand All @@ -125,6 +130,11 @@ msgstr "Conferma ispezione"
msgid "Confirmed"
msgstr "Confermata"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__amount
msgid "Cost"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__create_uid
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__create_uid
Expand All @@ -133,6 +143,11 @@ msgstr "Confermata"
msgid "Created by"
msgstr "Creato da"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__currency_id
msgid "Currency"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__create_date
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__create_date
Expand Down Expand Up @@ -503,6 +518,12 @@ msgstr "Messaggi"
msgid "Miles"
msgstr "Miglia"

#. module: fleet_vehicle_inspection
#: code:addons/fleet_vehicle_inspection/models/fleet_vehicle_inspection.py:0
#, python-format
msgid "Must select service type"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__my_activity_date_deadline
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__my_activity_date_deadline
Expand Down Expand Up @@ -666,6 +687,16 @@ msgstr "Descrizione risultato"
msgid "Sequence"
msgstr "Sequenza"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_id
msgid "Service"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_type_id
msgid "Service Type"
msgstr ""

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Set to Draft"
Expand Down Expand Up @@ -773,5 +804,10 @@ msgstr "Messaggi sito web"
msgid "Website communication history"
msgstr "Cronologia comunicazioni sito web"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__vendor_id
msgid "Vendor"
msgstr ""

#~ msgid "SMS Delivery error"
#~ msgstr "Errore consegna SMS"
36 changes: 36 additions & 0 deletions fleet_vehicle_inspection/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ msgstr "Cancelar"
msgid "Canceled"
msgstr "Cancelado(a)"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__company_id
msgid "Company"
msgstr ""

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Confirm Inspection"
Expand All @@ -126,6 +131,11 @@ msgstr "Confirmar Inspeção"
msgid "Confirmed"
msgstr "Confirmado"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__amount
msgid "Cost"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__create_uid
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__create_uid
Expand All @@ -134,6 +144,11 @@ msgstr "Confirmado"
msgid "Created by"
msgstr "Criado por"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__currency_id
msgid "Currency"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__create_date
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__create_date
Expand Down Expand Up @@ -503,6 +518,12 @@ msgstr "Mensagens"
msgid "Miles"
msgstr "Milhas"

#. module: fleet_vehicle_inspection
#: code:addons/fleet_vehicle_inspection/models/fleet_vehicle_inspection.py:0
#, python-format
msgid "Must select service type"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__my_activity_date_deadline
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection_item__my_activity_date_deadline
Expand Down Expand Up @@ -666,6 +687,16 @@ msgstr "Descrição do Resultado"
msgid "Sequence"
msgstr "Sequência"

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_id
msgid "Service"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__service_type_id
msgid "Service Type"
msgstr ""

#. module: fleet_vehicle_inspection
#: model_terms:ir.ui.view,arch_db:fleet_vehicle_inspection.fleet_vehicle_inspection_form_view
msgid "Set to Draft"
Expand Down Expand Up @@ -773,6 +804,11 @@ msgstr ""
msgid "Website communication history"
msgstr ""

#. module: fleet_vehicle_inspection
#: model:ir.model.fields,field_description:fleet_vehicle_inspection.field_fleet_vehicle_inspection__vendor_id
msgid "Vendor"
msgstr ""

#~ msgid "SMS Delivery error"
#~ msgstr "Erro de entrega de SMS"

Expand Down
38 changes: 38 additions & 0 deletions fleet_vehicle_inspection/models/fleet_vehicle_inspection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2020 - TODAY, Marcel Savegnago - Escodoo https://www.escodoo.com.br
# Copyright 2023 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
Expand Down Expand Up @@ -102,6 +103,21 @@ class FleetVehicleInspection(models.Model):
store=True,
)

amount = fields.Monetary("Cost")
service_type_id = fields.Many2one(
comodel_name="fleet.service.type",
string="Service Type",
domain=[("category", "=", "service")],
)
vendor_id = fields.Many2one("res.partner", "Vendor")
service_id = fields.Many2one(
comodel_name="fleet.vehicle.log.services", readonly=True, copy=False
)
company_id = fields.Many2one(
"res.company", "Company", default=lambda self: self.env.company
)
currency_id = fields.Many2one("res.currency", related="company_id.currency_id")

@api.depends("inspection_line_ids", "state")
def _compute_inspection_result(self):
for rec in self:
Expand Down Expand Up @@ -132,6 +148,9 @@ def create(self, vals):

def button_cancel(self):
records = self.filtered(lambda rec: rec.state in ["draft", "confirmed"])
services = records.filtered(lambda rec: rec.service_id).mapped("service_id")
if services:
services.sudo().unlink()
return records.write({"state": "cancel"})

def button_confirm(self):
Expand All @@ -145,6 +164,25 @@ def button_confirm(self):
raise ValidationError(
_("Only inspections in 'draft' or 'cancel' states can be confirmed")
)
if self.amount:
if not self.service_type_id:
raise ValidationError(_("Must select service type"))
self.service_id = (
self.env["fleet.vehicle.log.services"]
.create(
{
"service_type_id": self.service_type_id.id,
"description": self.name,
"vehicle_id": self.vehicle_id.id,
"amount": self.amount,
"odometer": self.odometer,
"vendor_id": self.vendor_id.id if self.vendor_id else False,
"state": "done",
}
)
.id
)

return self.write({"state": "confirmed"})

def button_draft(self):
Expand Down
Loading

0 comments on commit 3a0d84b

Please sign in to comment.