-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD][14.0] Add vehicle ownership, linking partners to vehicles #127 #130
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,106 @@ | ||
======================= | ||
Fleet Vehicle Ownership | ||
======================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c10570fb68e2d39efee546647fe22fcfc8b4b8022f384619750d9cd0d8428027 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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_ownership | ||
: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_ownership | ||
: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 extends the functionality of fleet to support vehicle owner | ||
data and to allow you to add vehicle ownership, linking partners to | ||
vehicles | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Use Cases / Context | ||
=================== | ||
|
||
This is an extension of the 'fleet.vehicle' model in the Odoo framework. | ||
It introduces a new field, 'owner_id', to track and associate the owner | ||
of a vehicle. | ||
|
||
Fields: | ||
|
||
- owner_id: Many2one field linking to the 'res.partner' model. It | ||
represents the owner of the vehicle. | ||
|
||
Usage: | ||
|
||
- This extension is particularly useful in scenarios where it's | ||
essential to associate each fleet vehicle with a specific owner. | ||
- The 'owner_id' field can be utilized to establish relationships with | ||
partners in the 'res.partner' model, facilitating clear ownership | ||
tracking. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
1. Go to the veichle form and associate an owner or go to the partner | ||
form and associate a vehicle. | ||
|
||
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_ownership%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 | ||
------- | ||
|
||
* RPSJR | ||
|
||
Contributors | ||
------------ | ||
|
||
- Raimundo Junior raimundopsjr@gmail.com | ||
|
||
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_ownership>`_ 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,19 @@ | ||
# Copyright 2023 RPSJR | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Fleet Vehicle Ownership", | ||
"summary": "Add vehicle ownership, linking partners to vehicles", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "RPSJR,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/fleet", | ||
"depends": ["fleet"], | ||
"data": [ | ||
"views/res_partner.xml", | ||
"views/fleet_vehicle.xml", | ||
], | ||
"demo": [ | ||
"demo/fleet_vehicle.xml", | ||
], | ||
} |
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 RPSJR | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo noupdate="1"> | ||
|
||
<record id="vehicle_29" model="fleet.vehicle"> | ||
<field name="license_plate">4-LH-44</field> | ||
<field name="vin_sn">44444</field> | ||
<field name="model_id">1</field> | ||
<field name="color">Silver</field> | ||
<field name="location">Silverstone</field> | ||
<field name="owner_id" ref="base.partner_demo" /> | ||
<field | ||
name="acquisition_date" | ||
eval="(DateTime.now() - timedelta(days=336)).strftime('%Y-%m-%d')" | ||
/> | ||
<field name="odometer_unit">kilometers</field> | ||
<field name="car_value">44000</field> | ||
</record> | ||
|
||
</odoo> |
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,2 @@ | ||
from . import fleet_vehicle | ||
from . import res_partner |
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,18 @@ | ||
# Copyright 2023 RPSJR | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class FleetVehicle(models.Model): | ||
|
||
_inherit = "fleet.vehicle" | ||
|
||
owner_id = fields.Many2one( | ||
"res.partner", | ||
"Owner", | ||
index=True, | ||
tracking=True, | ||
help="Owner of the vehicle", | ||
copy=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,38 @@ | ||
# Copyright 2023 RPSJR | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
@api.depends("vehicle_ids") | ||
def _compute_vehicle_count(self): | ||
for rec in self: | ||
rec.vehicle_count = len(rec.vehicle_ids) | ||
|
||
vehicle_ids = fields.One2many( | ||
"fleet.vehicle", | ||
"owner_id", | ||
required=True, | ||
help="Vehicles owned by this partner", | ||
) | ||
vehicle_count = fields.Integer( | ||
compute=_compute_vehicle_count, string="Number of Vehicles", store=True | ||
) | ||
|
||
def action_view_vehicles(self): | ||
self.ensure_one() | ||
xmlid = "fleet.fleet_vehicle_action" | ||
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid) | ||
action["context"] = self.env.context.copy() | ||
action["context"].update({"default_owner_id": self.id}) | ||
if self.vehicle_count > 1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recomend to add a default_owner_id = self.id on context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
action["domain"] = [("id", "in", self.vehicle_ids.ids)] | ||
else: | ||
action["views"] = [ | ||
(self.env.ref("fleet.fleet_vehicle_view_form").id, "form") | ||
] | ||
action["res_id"] = self.vehicle_ids and self.vehicle_ids.ids[0] or False | ||
return action |
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,9 @@ | ||
This is an extension of the 'fleet.vehicle' model in the Odoo framework. | ||
It introduces a new field, 'owner_id', to track and associate the owner of a vehicle. | ||
|
||
Fields: | ||
- owner_id: Many2one field linking to the 'res.partner' model. It represents the owner of the vehicle. | ||
|
||
Usage: | ||
- This extension is particularly useful in scenarios where it's essential to associate each fleet vehicle with a specific owner. | ||
- The 'owner_id' field can be utilized to establish relationships with partners in the 'res.partner' model, facilitating clear ownership tracking. |
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 @@ | ||
- Raimundo Junior <raimundopsjr@gmail.com> |
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 extends the functionality of fleet to support vehicle owner data and to allow you to add vehicle ownership, linking partners to vehicles |
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 @@ | ||
To use this module, you need to: | ||
|
||
1. Go to the veichle form and associate an owner or go to the partner form and associate a vehicle. |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add self.ensure_one()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done