# Account Shared Bank Cash ## Overview This custom Odoo 19 module removes the standard restriction that prevents Chart of Accounts (COA) of type **Bank and Cash** (`asset_cash`) from being shared across multiple companies. By default, Odoo restricts a Bank and Cash account to a single company. This module patches `_check_company_consistency` on the `account.account` model to allow you to configure multiple companies for a single Bank/Cash account. This is particularly useful for setups where multiple Point of Sale (POS) shops across different companies deposit into the same physical bank account or cash account. ## Features ### 1. Shared COA Support - Overrides `account.account` company validation to allow `len(company_ids) > 1` on `asset_cash` accounts. - Ensures POS payments and closing entries seamlessly use the shared account. ### 2. Automated Inter-Company Clearing When a branch-side POS session is closed, the module automates the inter-company accounting flow: - **Branch Company (Origin)**: - Aggregates all bank clearing entries into a **single aggregated journal entry** (usually just 2 lines: Total Receivable vs Total Inter-company Account). - Automatically reconciles these clearing lines against the main POS session move. - Visually links the clearing moves to the POS Session's **"Journal Items"** dashboard. - **Parent Company (Destination)**: - Automatically creates **separate mirror journal entries** for each payment method (e.g., separate entries for BCA, BTN, BRI). - Debits the parent bank's **Outstanding Receipt Account**, allowing for seamless reconciliation against incoming bank statement lines in the parent's accounting dashboard. - Credits the Inter-company Liability account (e.g., `229101 Hubungan RK`). ### 3. Centralized Vendor Payment Enables branches to pay vendor bills from a bank account managed by a parent company: - **Branch-Side**: Intercepts the "Register Payment" wizard. Instead of creating a standard payment, it generates a clearing entry that moves the liability from the Vendor (Accounts Payable) to the Parent Company (Inter-company Account). - **Parent-Side**: Automatically creates an actual `account.payment` record in the parent company, paying out of the parent bank journal and debiting the inter-company clearing account. - **Workflow**: Vendor bill remains in the branch, but is marked as **Paid** via the clearing mechanism. The actual cash outflow and bank reconciliation happen in the parent. ### 4. Multi-Company POS Order and Checkout Bypass Solves Odoo's restrictive `Access to unauthorized or invalid companies` error/warnings in logs when branch cashiers place orders, checkout, or sync POS sessions: - **Environment & Session Sanitization**: Overrides `ir.http._pre_dispatch` and `_dispatch` to safely query the cashier's authorized companies using `sudo()`, and dynamically filters out unauthorized or parent company IDs (such as parent company `2`) from `allowed_company_ids` in request parameters (`request.params`), HTTP sessions (`request.session.context`), and environment context (`request.env.context`). - **Sudo Order Post-Processing**: Inherits `pos.order` to run post-processing (`_process_saved_order`, including picking generation, cost/method computation, and payment posting) under `sudo()`. This allows Odoo to safely read company-dependent properties (like `cost_method` or `property_cost_method`) and generate inventory pickings without triggering security warnings in `environments.py`. ### 5. Centralized Cash Bank Reconciliation Patch Enables matching of cash journal entries (e.g. from the centralized cash journal) in Odoo's standard bank reconciliation widget: - **Reconciliation Candidate Expansion**: Patches the standard `account.move.line` search method (`_search_account_id`) to automatically include `asset_cash` accounts when filtering candidate line searches. This allows users to reconcile bank statement lines in the parent company directly against mirror/clearing cash entries. ## Configuration ### 1. POS Inter-Company Clearing To enable the automated inter-company clearing, navigate to **Point of Sale > Configuration > Payment Methods** and configure the following in the "Inter-Company Clearing" section: - **Parent Company**: Select the target company (e.g., OT). - **Parent Bank Journal**: Select the journal in the parent company that receives the funds. - **Parent Inter-company Account**: The liability account in the parent company (e.g., `229101 Hubungan RK`). - **Parent Clearing Journal**: The journal in the parent company used to record these mirror entries (e.g., "Inter-Company Clearing"). ### 2. Centralized Vendor Payment Configure a **Bank/Cash Journal** in the branch company to act as a bridge: 1. Open the journal form (**Accounting > Configuration > Journals**). 2. Go to the **Centralized Payment** tab. 3. Enable **Is Centralized**. 4. Set the **Parent Company**, **Parent Journal**, and both **Inter-Company (RK) Accounts**. 5. When registering a payment on a vendor bill, select this journal to trigger the cross-company flow. ## Author - **Suherdy Yacob**