Description
An accounting integration enhancement that automatically links journal entries to their originating sales orders and purchase orders. The module adds computed Sales Order and Purchase Order columns to the Journal Entries view, enabling accountants to quickly trace inventory valuation entries and invoices back to their source business documents.
Business Challenge
Van Thiel's accounting team struggled to trace journal entries back to their source transactions, particularly for:
- Inventory valuation entries from manufacturing operations
- Stock move journal entries linked to customer deliveries
- Complex MRP production flows involving raw materials and finished goods
- Purchase receipts and vendor bill reconciliations
- Manual auditing taking hours to connect journal entries to business context
- Difficulty explaining cost variances to management without order references
Solution Approach
Matthias developed an intelligent linking system that traces journal entries through multiple relationship paths:
- Multi-Path Tracing: Checks stock moves, invoice lines, MRP productions, and procurement groups
- MRP Integration: Follows both raw material consumption and finished product production moves
- Searchable Fields: Custom search methods allow filtering by SO/PO name or ID
- Fallback Logic: Hierarchical approach tries direct links before inferring from related records
Technical Implementation
The module extends account.move with sophisticated computed fields and search capabilities:
- Computed Many2one fields
sale_order_idandpurchase_order_idstored in database - Method
_compute_related_orders()implements multi-step tracing logic with 9+ relationship paths - Checks
stock_move_idrelationships first for direct valuation entries - Traces through
raw_material_production_idandproduction_idfor MRP context - Falls back to
invoice_line_idsmappings when stock move links are absent - Custom
_search_sale_order_id()and_search_purchase_order_id()enable domain filtering - Handles edge cases with defensive programming using
getattr()for optional fields
Results & Impact
The accounting team can now instantly see the sales or purchase order context for any journal entry. Auditing time reduced by 70%, and management reports now include clear traceability to customer orders. The solution handles Van Thiel's complex make-to-order manufacturing flows with complete accuracy.