-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] fleet_vehicle_capacity: add new module
- Loading branch information
1 parent
74124af
commit 069f332
Showing
17 changed files
with
947 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
====================== | ||
Fleet Vehicle Capacity | ||
====================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c6363705ebe10d7daf6de26c5e8c9689066d8cb8d4c63d5b2e2eca9fc1fe5207 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-OCA%2Ffleet-lightgray.png?logo=github | ||
:target: https://github.com/OCA/fleet/tree/14.0/fleet_vehicle_capacity | ||
:alt: OCA/fleet | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/fleet-14-0/fleet-14-0-fleet_vehicle_capacity | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/fleet&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module adds fields to manage the weight and volume capacity in the | ||
vehicle model. It is also designed to be easily expandable, allowing the | ||
addition of other vehicle-specific capacities in the future as needed. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/fleet/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 <https://github.com/OCA/fleet/issues/new?body=module:%20fleet_vehicle_capacity%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Escodoo | ||
|
||
Contributors | ||
------------ | ||
|
||
- ``Escodoo <https://www.escodoo.com.br>``\ \_: | ||
|
||
- Marcel Savegnago [email protected] | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/fleet <https://github.com/OCA/fleet/tree/14.0/fleet_vehicle_capacity>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 - TODAY, Escodoo | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Fleet Vehicle Capacity", | ||
"summary": """ | ||
Add capacity fields to vehicles""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Escodoo,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/fleet", | ||
"depends": [ | ||
"fleet", | ||
"uom", | ||
], | ||
"data": [ | ||
"views/res_config_settings.xml", | ||
"views/fleet_vehicle_model.xml", | ||
"views/fleet_vehicle.xml", | ||
], | ||
"demo": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import fleet_vehicle | ||
from . import fleet_vehicle_model | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2024 - TODAY, Marcel Savegnago <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class FleetVehicle(models.Model): | ||
|
||
_inherit = "fleet.vehicle" | ||
|
||
vehicle_weight = fields.Float( | ||
related="model_id.vehicle_weight", | ||
string="Vehicle Weight", | ||
help="The weight of the vehicle.", | ||
readonly=False, | ||
) | ||
|
||
weight_capacity = fields.Float( | ||
related="model_id.weight_capacity", | ||
string="Weight Capacity", | ||
help="The maximum weight capacity the vehicle can support.", | ||
readonly=False, | ||
) | ||
|
||
volume_capacity = fields.Float( | ||
related="model_id.volume_capacity", | ||
string="Volume Capacity", | ||
help="The maximum volume capacity the vehicle can support.", | ||
readonly=False, | ||
) | ||
|
||
passenger_capacity = fields.Float( | ||
related="model_id.passenger_capacity", | ||
string="Passenger Capacity", | ||
help="The maximum passenger capacity the vehicle can support.", | ||
readonly=False, | ||
) | ||
|
||
weight_uom_id = fields.Many2one( | ||
related="model_id.weight_uom_id", | ||
string="Weight and Capacity UOM", | ||
) | ||
|
||
volume_uom_id = fields.Many2one( | ||
related="model_id.volume_uom_id", | ||
string="Volume Capacity UOM", | ||
) | ||
|
||
passenger_uom_id = fields.Many2one( | ||
related="model_id.passenger_uom_id", | ||
string="Passenger Capacity UOM", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Copyright 2024 - TODAY, Marcel Savegnago <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import logging | ||
|
||
from odoo import fields, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class FleetVehicleModel(models.Model): | ||
_inherit = "fleet.vehicle.model" | ||
|
||
vehicle_weight = fields.Float( | ||
string="Vehicle Weight", help="The weight of the vehicle." | ||
) | ||
|
||
weight_capacity = fields.Float( | ||
string="Weight Capacity", | ||
help="The maximum weight capacity the vehicle can support.", | ||
) | ||
|
||
volume_capacity = fields.Float( | ||
string="Volume Capacity", | ||
help="The maximum volume capacity the vehicle can support.", | ||
) | ||
|
||
passenger_capacity = fields.Float( | ||
string="Passenger Capacity", | ||
help="The maximum passenger capacity the vehicle can support.", | ||
) | ||
|
||
def _get_vehicle_weight_uom_id_from_ir_config_parameter(self): | ||
uom_id = ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("fleet.default_vehicle_weight_uom_id") | ||
) | ||
if uom_id: | ||
try: | ||
return int(uom_id) | ||
except ValueError: | ||
_logger.error("Invalid Vehicle Weight UOM ID format: %s", uom_id) | ||
return False | ||
else: | ||
return self.env["res.config.settings"]._default_vehicle_weight_uom_id() | ||
|
||
def _get_vehicle_volume_uom_id_from_ir_config_parameter(self): | ||
uom_id = ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("fleet.default_vehicle_volume_uom_id") | ||
) | ||
if uom_id: | ||
try: | ||
return int(uom_id) | ||
except ValueError: | ||
_logger.error("Invalid Vehicle Volume UOM ID format: %s", uom_id) | ||
return False | ||
else: | ||
return self.env["res.config.settings"]._default_vehicle_volume_uom_id() | ||
|
||
def _get_vehicle_passenger_uom_id_from_ir_config_parameter(self): | ||
uom_id = ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("fleet.default_vehicle_passenger_uom_id") | ||
) | ||
if uom_id: | ||
try: | ||
return int(uom_id) | ||
except ValueError: | ||
_logger.error("Invalid Vehicle Passenger UOM ID format: %s", uom_id) | ||
return False | ||
else: | ||
return self.env["res.config.settings"]._default_vehicle_passenger_uom_id() | ||
|
||
weight_uom_id = fields.Many2one( | ||
"uom.uom", | ||
string="Weight and Capacity UOM", | ||
domain=lambda self: [ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_kgm").id) | ||
], | ||
default=lambda x: x._get_vehicle_weight_uom_id_from_ir_config_parameter(), | ||
) | ||
|
||
volume_uom_id = fields.Many2one( | ||
"uom.uom", | ||
string="Volume Capacity UOM", | ||
domain=lambda self: [ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_vol").id) | ||
], | ||
default=lambda x: x._get_vehicle_volume_uom_id_from_ir_config_parameter(), | ||
) | ||
|
||
passenger_uom_id = fields.Many2one( | ||
"uom.uom", | ||
string="Passenger Capacity UOM", | ||
domain=lambda self: [ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_unit").id) | ||
], | ||
default=lambda x: x._get_vehicle_passenger_uom_id_from_ir_config_parameter(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Copyright 2024 - TODAY, Marcel Savegnago <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import logging | ||
|
||
from odoo import api, fields, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
|
||
_inherit = "res.config.settings" | ||
|
||
vehicle_weight_uom_id = fields.Many2one( | ||
"uom.uom", | ||
string="Default Vehicle Weight and Capacity UOM", | ||
domain=lambda self: [ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_kgm").id), | ||
], | ||
default=lambda self: self._default_vehicle_weight_uom_id(), | ||
help="Default Unit of measure for vehicle weight and capacity.", | ||
default_model="res.config.settings", | ||
config_parameter="fleet.default_vehicle_weight_uom_id", | ||
) | ||
|
||
vehicle_volume_uom_id = fields.Many2one( | ||
"uom.uom", | ||
string="Default Vehicle Volume Capacity UOM", | ||
domain=lambda self: [ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_vol").id), | ||
], | ||
default=lambda self: self._default_vehicle_volume_uom_id(), | ||
help="Default Unit of measure for vehicle volume capacity.", | ||
default_model="res.config.settings", | ||
config_parameter="fleet.default_vehicle_volume_uom_id", | ||
) | ||
|
||
vehicle_passenger_uom_id = fields.Many2one( | ||
"uom.uom", | ||
string="Default Vehicle Passenger Capacity UOM", | ||
domain=lambda self: [ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_unit").id), | ||
], | ||
default=lambda self: self._default_vehicle_passenger_uom_id(), | ||
help="Default Unit of measure for vehicle passenger capacity.", | ||
default_model="res.config.settings", | ||
config_parameter="fleet.default_vehicle_passenger_uom_id", | ||
) | ||
|
||
@api.model | ||
def _default_vehicle_weight_uom_id(self): | ||
"""Method to find and return the default UOM for vehicle weight and capacity.""" | ||
uom = self.env["uom.uom"].search( | ||
[ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_kgm").id), | ||
("uom_type", "=", "bigger"), | ||
], | ||
limit=1, | ||
order="id", | ||
) | ||
return uom.id if uom else False | ||
|
||
@api.model | ||
def _default_vehicle_volume_uom_id(self): | ||
"""Method to find and return the default UOM for vehicle volume capacity.""" | ||
uom = self.env["uom.uom"].search( | ||
[ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_vol").id), | ||
("uom_type", "=", "bigger"), | ||
], | ||
limit=1, | ||
order="id", | ||
) | ||
return uom.id if uom else False | ||
|
||
@api.model | ||
def _default_vehicle_passenger_uom_id(self): | ||
"""Method to find and return the default UOM for vehicle passenger capacity.""" | ||
uom = self.env["uom.uom"].search( | ||
[ | ||
("category_id", "=", self.env.ref("uom.product_uom_categ_unit").id), | ||
("uom_type", "=", "reference"), | ||
], | ||
limit=1, | ||
order="id", | ||
) | ||
return uom.id if uom else False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module adds fields to manage the weight and volume capacity in the vehicle model. It is also designed to be easily expandable, allowing the addition of other vehicle-specific capacities in the future as needed. |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.