[18.0][ADD]fleet_traffic_infractions_account: add new module
Depends on: #184 fleet_vehicle_assignation_log_datetime #185 fleet_traffic_infractions
[ADD] fleet_traffic_infractions_account: Financial integration for traffic infractions.
This pull request introduces the fleet_traffic_infractions_account module. It serves as a bridge to connect the operational data from the fleet_traffic_infractions module with Odoo's accounting functionalities, featuring a powerful, rule-based engine for applying driver invoicing policies.
Motivation
The fleet_traffic_infractions module provides a robust foundation for the operational tracking of traffic fines. However, to complete the business process, a financial layer is required to handle the invoicing of drivers and the payment of fines to issuing agencies.
This functionality is intentionally separated into this bridge module for several key reasons:
- To Avoid Forced Dependencies: Users who only need core operational tracking are not required to install
accountandproduct. - To Promote Modularity: It adheres to the OCA principle of single responsibility. This module's sole purpose is to manage the financial transactions related to infractions.
- To Enable Extensibility: This design allows for other types of financial integrations in the future (e.g.,
hr_expense).
Implementation
This module extends the fleet_traffic_infractions module by adding the following features:
-
Dependencies: It adds dependencies on
fleet_traffic_infractionsandaccount. -
Financial Workflow: It extends the state machine of the
fleet.traffic.infractionsmodel to include a full financial workflow. TheConfirmedstate now transitions to:To Invoice Driver->To Create Agency Bill->Processed. -
Rule-Based Driver Invoicing with "Invoicing Rules":
- The core feature of this module is a new
fleet.traffic.infraction.invoicing.termmodel, designed as a powerful rule engine. This provides a highly flexible, "compressive" system for managing different invoicing policies. - Each rule combines a financial policy (e.g., invoice the driver, add fees, apply discounts) with a
driver_domain. - The
driver_domainuses Odoo's domain builder to precisely target which drivers the rule applies to (e.g., by department, employee tag, partner type, etc.). - A
sequencefield allows for prioritizing these rules. The system evaluates them in order and applies the first matching rule it finds. This enables complex logic, such as specific rules for certain teams and a final "catch-all" rule for everyone else. - A "Create Driver Invoice" button on the infraction form executes this logic to generate the correct
account.movefor the driver based on the matched rule.
- The core feature of this module is a new
-
Configurable Agency Billing (Company Policy):
- A new company-wide setting is added under
Fleet > Configuration > Settingsto define how fines from issuing agencies are recorded. - This provides two distinct methods:
- Create Vendor Bill: Treats the fine as a standard purchase from the agency.
- Create Miscellaneous Journal Entry: Treats the fine as a direct expense (e.g., a tax), keeping the transaction out of the standard purchase workflow.
- A new company-wide setting is added under
-
Model & View Extensions:
- A
Fine Productfield is added to thefleet.traffic.infraction.typemodel to link infractions to specific income/expense accounts. - The
fleet.traffic.infractionsform is updated with new buttons for the financial workflow and smart links to the generated accounting entries. - An
applied_invoicing_term_idfield has been added to the infraction form to clearly show the user which specific rule was matched and applied, ensuring transparency.
- A