-
-
Notifications
You must be signed in to change notification settings - Fork 123
[16.0][ADD] fleet_vehicle_purchase_link: add new module #231
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
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| .. image:: https://odoo-community.org/readme-banner-image | ||
| :target: https://odoo-community.org/get-involved?utm_source=readme | ||
| :alt: Odoo Community Association | ||
|
|
||
| =========================== | ||
| Fleet Vehicle Purchase Link | ||
| =========================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:0bdafb694ee2bf7cb4d2700daabba38fa885ceb18ef56a8feeba48df6cf20e48 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |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/license-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/16.0/fleet_vehicle_purchase_link | ||
| :alt: OCA/fleet | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/fleet-16-0/fleet-16-0-fleet_vehicle_purchase_link | ||
| :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=16.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module links fleet vehicles to purchases, allowing a vehicle to be set | ||
| on each purchase order line and providing a smart button and menu to navigate | ||
| between vehicles and their related purchases. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| To use this module, you need to: | ||
|
|
||
| 1. Go to the Purchase application and open or create a purchase order. | ||
| 2. On each order line, set the related fleet vehicle. | ||
| 3. Go to the Fleet application and open a vehicle to see the Purchases smart | ||
| button with the count of linked purchase order lines; click it to list them. | ||
| 4. Go to Fleet > Fleet > Purchases to list the purchase orders that have at | ||
| least one line linked to 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_purchase_link%0Aversion:%2016.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>`_: | ||
|
|
||
| * Wesley Oliveira <wesley.oliveira@escodoo.com.br> | ||
|
|
||
| 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. | ||
|
|
||
| .. |maintainer-WesleyOliveira98| image:: https://github.com/WesleyOliveira98.png?size=40px | ||
| :target: https://github.com/WesleyOliveira98 | ||
| :alt: WesleyOliveira98 | ||
|
|
||
| Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-WesleyOliveira98| | ||
|
|
||
| This module is part of the `OCA/fleet <https://github.com/OCA/fleet/tree/16.0/fleet_vehicle_purchase_link>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||
| # Copyright 2026 - TODAY, Escodoo | ||||||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||||||
|
|
||||||
| { | ||||||
| "name": "Fleet Vehicle Purchase Link", | ||||||
| "summary": """ | ||||||
| Link fleet vehicles to purchase order lines""", | ||||||
| "version": "16.0.1.0.0", | ||||||
| "license": "AGPL-3", | ||||||
| "author": "Escodoo,Odoo Community Association (OCA)", | ||||||
|
Contributor
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.
Suggested change
|
||||||
| "website": "https://github.com/OCA/fleet", | ||||||
| "category": "Fleet", | ||||||
| "maintainers": ["WesleyOliveira98"], | ||||||
| "depends": ["fleet_vehicle_purchase"], | ||||||
| "data": [ | ||||||
| "views/fleet_vehicle_views.xml", | ||||||
| ], | ||||||
| "installable": True, | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * fleet_vehicle_purchase_link | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 16.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "Last-Translator: \n" | ||
| "Language-Team: \n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Plural-Forms: \n" | ||
|
|
||
| #. module: fleet_vehicle_purchase_link | ||
| #. odoo-python | ||
| #: code:addons/fleet_vehicle_purchase_link/models/fleet_vehicle.py:0 | ||
| #: model:ir.model.fields,field_description:fleet_vehicle_purchase_link.field_fleet_vehicle__purchase_line_count | ||
| #, python-format | ||
| msgid "Purchase Lines" | ||
| msgstr "" | ||
|
|
||
| #. module: fleet_vehicle_purchase_link | ||
| #: model:ir.actions.act_window,name:fleet_vehicle_purchase_link.purchase_order_with_vehicle_action | ||
| #: model:ir.ui.menu,name:fleet_vehicle_purchase_link.fleet_purchase_menu | ||
| #: model_terms:ir.ui.view,arch_db:fleet_vehicle_purchase_link.fleet_vehicle_view_form_inherit | ||
| msgid "Purchases" | ||
| msgstr "" | ||
|
|
||
| #. module: fleet_vehicle_purchase_link | ||
| #: model:ir.model,name:fleet_vehicle_purchase_link.model_fleet_vehicle | ||
| msgid "Vehicle" | ||
| msgstr "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import fleet_vehicle |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| # Copyright 2026 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br> | ||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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.
Suggested change
Apply this copyright header format across all other files as well. |
||||||||||||||||||||||||||||||||||||||||||||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| from odoo import _, fields, models | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| class FleetVehicle(models.Model): | ||||||||||||||||||||||||||||||||||||||||||||
| _inherit = "fleet.vehicle" | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| purchase_line_count = fields.Integer( | ||||||||||||||||||||||||||||||||||||||||||||
| string="Purchase Lines", | ||||||||||||||||||||||||||||||||||||||||||||
| compute="_compute_purchase_line_count", | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def _compute_purchase_line_count(self): | ||||||||||||||||||||||||||||||||||||||||||||
| line_model = self.env["purchase.order.line"] | ||||||||||||||||||||||||||||||||||||||||||||
| for vehicle in self: | ||||||||||||||||||||||||||||||||||||||||||||
| vehicle.purchase_line_count = line_model.search_count( | ||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||
| ("fleet_vehicle_id", "=", vehicle.id), | ||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+22
Contributor
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.
Suggested change
Contributor
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. Reduces N SQL queries (one per vehicle) to a single read_group() query, improving performance on list views with multiple records. |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def action_view_purchase_lines(self): | ||||||||||||||||||||||||||||||||||||||||||||
| self.ensure_one() | ||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||
| "name": _("Purchase Lines"), | ||||||||||||||||||||||||||||||||||||||||||||
| "type": "ir.actions.act_window", | ||||||||||||||||||||||||||||||||||||||||||||
| "res_model": "purchase.order.line", | ||||||||||||||||||||||||||||||||||||||||||||
| "view_mode": "tree,form", | ||||||||||||||||||||||||||||||||||||||||||||
| "domain": [("fleet_vehicle_id", "=", self.id)], | ||||||||||||||||||||||||||||||||||||||||||||
| "context": {"default_fleet_vehicle_id": self.id}, | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| * `Escodoo <https://www.escodoo.com.br>`_: | ||
|
|
||
| * Wesley Oliveira <wesley.oliveira@escodoo.com.br> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| This module links fleet vehicles to purchases, allowing a vehicle to be set | ||
| on each purchase order line and providing a smart button and menu to navigate | ||
| between vehicles and their related purchases. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| To use this module, you need to: | ||
|
|
||
| 1. Go to the Purchase application and open or create a purchase order. | ||
| 2. On each order line, set the related fleet vehicle. | ||
| 3. Go to the Fleet application and open a vehicle to see the Purchases smart | ||
| button with the count of linked purchase order lines; click it to list them. | ||
| 4. Go to Fleet > Fleet > Purchases to list the purchase orders that have at | ||
| least one line linked to a vehicle. |
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.