[16.0][ADD] fleet_vehicle_purchase_link: add new module - #231
Open
WesleyOliveira98 wants to merge 1 commit into
Open
[16.0][ADD] fleet_vehicle_purchase_link: add new module#231WesleyOliveira98 wants to merge 1 commit into
WesleyOliveira98 wants to merge 1 commit into
Conversation
WesleyOliveira98
force-pushed
the
16.0-add-fleet_vehicle_purchase_link
branch
from
August 21, 2026 13:37
aeabc73 to
2ca0172
Compare
marcelsavegnago
requested review from
BhaveshHeliconia,
CristianoMafraJunior and
kaynnan
August 24, 2026 17:19
BhaveshHeliconia
suggested changes
Aug 25, 2026
Comment on lines
+15
to
+22
| 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), | ||
| ] | ||
| ) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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), | |
| ] | |
| ) | |
| def _compute_purchase_line_count(self): | |
| line_model = self.env["purchase.order.line"] | |
| data = line_model.read_group( | |
| [("fleet_vehicle_id", "in", self.ids)], | |
| ["fleet_vehicle_id"], | |
| ["fleet_vehicle_id"], | |
| ) | |
| mapped_data = { | |
| item["fleet_vehicle_id"][0]: item["fleet_vehicle_id_count"] | |
| for item in data | |
| } | |
| for vehicle in self: | |
| vehicle.purchase_line_count = mapped_data.get(vehicle.id, 0) |
Contributor
There was a problem hiding this comment.
Reduces N SQL queries (one per vehicle) to a single read_group() query, improving performance on list views with multiple records.
Comment on lines
+6
to
+7
| "summary": """ | ||
| Link fleet vehicles to purchase order lines""", |
Contributor
There was a problem hiding this comment.
Suggested change
| "summary": """ | |
| Link fleet vehicles to purchase order lines""", | |
| "summary": "Link fleet vehicles to purchase order lines", |
| 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.
Suggested change
| "author": "Escodoo,Odoo Community Association (OCA)", | |
| "author": "Escodoo, Odoo Community Association (OCA)", |
| <field | ||
| name="purchase_line_count" | ||
| widget="statinfo" | ||
| string="Purchases" |
Contributor
There was a problem hiding this comment.
Suggested change
| string="Purchases" | |
| string="Purchase Lines" |
The base module fleet_vehicle_purchase already shows "Purchase Orders". Having "Purchases" next to it is confusing, so "Purchase Lines" clearly indicates that this button counts order lines.
| @@ -0,0 +1,33 @@ | |||
| # Copyright 2026 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br> | |||
Contributor
There was a problem hiding this comment.
Suggested change
| # Copyright 2026 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br> | |
| # Copyright 2026 Escodoo - Wesley Oliveira <wesley.oliveira@escodoo.com.br> |
Apply this copyright header format across all other files as well.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
cc: @marcelsavegnago @kaynnan @CristianoMafraJunior @medicegabriel @MarcusPDL