Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fleet_vehicle_category/views/fleet_vehicle_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<field name="name" />
</h1>
</div>
<group name="main" />
<notebook>
<page name="description_page" string="Description">
<field name="description" type="html" />
Expand Down
104 changes: 104 additions & 0 deletions fleet_vehicle_category_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
======================
Fleet Vehicle Analytic
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:43e12b9a776f7464fecf6608fc4ee45d591ff74590d37fea45956cbe2b3d34eb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/18.0/fleet_vehicle_category_analytic
:alt: OCA/fleet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/fleet-18-0/fleet-18-0-fleet_vehicle_category_analytic
: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=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds analytic account definition per vehicle category. It
define this analytic account on the analytic distribution of account
move line.

**Table of contents**

.. contents::
:local:

Usage
=====

Prerequisites: Analytic enabled, Vehicle added to Vehicle Categories.

1. Browse to "Fleet / Configuration / Categories" and define an Analytic
Account on a Category
2. Create a new invoice from "Accounting / Vendors / Bills / [+ New]"
3. On the invoice line, set a vehicle belonging to the Category modified
at step 1. To view the "Vehicule" column on invoice lines, do not
forget to add the column.
4. Look at the Analytic Distribution: the Analytic Account previously
defined on the Category is added at 100%.

Warning: this analytic is very simply merged / added to the existing
analytic distribution, which may lead to more than 100% distribution.

Changelog
=========

18.0.1.0.0 (2026-02-27)
-----------------------

- [NEW] Module creation

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_category_analytic%0Aversion:%2018.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
-------

* Arnaud Layec
* Akretion

Contributors
------------

- Arnaud Layec <arnaud.layec@akretion.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/18.0/fleet_vehicle_category_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions fleet_vehicle_category_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions fleet_vehicle_category_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2026 Arnaud Layec (<arnaud.layec@akretion.com>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Fleet Vehicle Analytic",
"summary": """
Define Analytic Account per vehicle category
""",
"version": "18.0.1.0.0",
"category": "Human Resources",
"author": "Arnaud Layec, Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/fleet",
"license": "AGPL-3",
"depends": ["account_fleet", "fleet_vehicle_category"],
"data": ["views/fleet_vehicle_category_views.xml"],
"installable": True,
"auto_install": False,
}
1 change: 1 addition & 0 deletions fleet_vehicle_category_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move_line, fleet_vehicle_category
30 changes: 30 additions & 0 deletions fleet_vehicle_category_analytic/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2026 - Arnaud LAYEC <arnaud.layec@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class AccountMoveLine(models.Model):
_inherit = ["account.move.line"]

@api.depends("vehicle_id")
def _compute_analytic_distribution(self):
"""Inject the analytic account of the vehicle's category.
When the account is already present in the distribution its
percentage is kept as-is to avoid overriding manual adjustments made
through other sources; otherwise it is added at 100%.
"""
res = super()._compute_analytic_distribution()
for line in self:
if not line.vehicle_id:
continue
account = line.vehicle_id.vehicle_category_id.analytic_account_id
if not account:
continue

distribution = line.analytic_distribution or {}
account_key = str(account.id)
if account_key not in distribution:
distribution[account_key] = 100
line.analytic_distribution = distribution
return res
19 changes: 19 additions & 0 deletions fleet_vehicle_category_analytic/models/fleet_vehicle_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2026 - Arnaud LAYEC <arnaud.layec@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class FleetVehicleCategory(models.Model):
_inherit = ["fleet.vehicle.category"]

company_id = fields.Many2one(
comodel_name="res.company",
readonly=True,
default=lambda self: self.env.company.root_id,
)
analytic_account_id = fields.Many2one(
comodel_name="account.analytic.account",
string="Analytic Account",
check_company=True,
)
3 changes: 3 additions & 0 deletions fleet_vehicle_category_analytic/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions fleet_vehicle_category_analytic/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Arnaud Layec \<<arnaud.layec@akretion.com>\>
2 changes: 2 additions & 0 deletions fleet_vehicle_category_analytic/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module adds analytic account definition per vehicle category.
It define this analytic account on the analytic distribution of account move line.
3 changes: 3 additions & 0 deletions fleet_vehicle_category_analytic/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 18.0.1.0.0 (2026-02-27)

- \[NEW\] Module creation
12 changes: 12 additions & 0 deletions fleet_vehicle_category_analytic/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Prerequisites: Analytic enabled, Vehicle added to Vehicle Categories.

1. Browse to "Fleet / Configuration / Categories" and define an Analytic Account on a Category
2. Create a new invoice from "Accounting / Vendors / Bills / [+ New]"
3. On the invoice line, set a vehicle belonging to the Category modified at step 1.
To view the "Vehicule" column on invoice lines, do not forget to add the column.
4. Look at the Analytic Distribution: the Analytic Account previously defined on the Category
is added at 100%.

Warning: this analytic is very simply merged / added to the existing analytic distribution,
which may lead to more than 100% distribution.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading