Skip to content

Conversation

@rpsjr
Copy link

@rpsjr rpsjr commented Sep 28, 2025

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 account and product.
  • 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_infractions and account.

  • Financial Workflow: It extends the state machine of the fleet.traffic.infractions model to include a full financial workflow. The Confirmed state 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.term model, 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_domain uses Odoo's domain builder to precisely target which drivers the rule applies to (e.g., by department, employee tag, partner type, etc.).
    • A sequence field 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.move for the driver based on the matched rule.
  • Configurable Agency Billing (Company Policy):

    • A new company-wide setting is added under Fleet > Configuration > Settings to define how fines from issuing agencies are recorded.
    • This provides two distinct methods:
      1. Create Vendor Bill: Treats the fine as a standard purchase from the agency.
      2. Create Miscellaneous Journal Entry: Treats the fine as a direct expense (e.g., a tax), keeping the transaction out of the standard purchase workflow.
  • Model & View Extensions:

    • A Fine Product field is added to the fleet.traffic.infraction.type model to link infractions to specific income/expense accounts.
    • The fleet.traffic.infractions form is updated with new buttons for the financial workflow and smart links to the generated accounting entries.
    • An applied_invoicing_term_id field has been added to the infraction form to clearly show the user which specific rule was matched and applied, ensuring transparency.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant