Skip to content

[16.0][ADD] fleet_vehicle_purchase_link: add new module - #231

Open
WesleyOliveira98 wants to merge 1 commit into
OCA:16.0from
Escodoo:16.0-add-fleet_vehicle_purchase_link
Open

[16.0][ADD] fleet_vehicle_purchase_link: add new module#231
WesleyOliveira98 wants to merge 1 commit into
OCA:16.0from
Escodoo:16.0-add-fleet_vehicle_purchase_link

Conversation

@WesleyOliveira98

Copy link
Copy Markdown
Contributor

@OCA-git-bot OCA-git-bot added series:16.0 mod:fleet_vehicle_purchase_link Module fleet_vehicle_purchase_link labels Aug 21, 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),
]
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Comment on lines +6 to +7
"summary": """
Link fleet vehicles to purchase order lines""",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"author": "Escodoo,Odoo Community Association (OCA)",
"author": "Escodoo, Odoo Community Association (OCA)",

<field
name="purchase_line_count"
widget="statinfo"
string="Purchases"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:fleet_vehicle_purchase_link Module fleet_vehicle_purchase_link series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants