# POS Export BC Format This is a custom Odoo 19 module designed specifically to export Point of Sale (POS) orders and sales data into a highly structured Excel layout required for "MIE MAPAN INVOICES". This module focuses on ensuring accurate accounting aggregations, proper chronological date handling, and layout consistency for reporting purposes. ## Key Features 1. **Custom Row-Aggregated Excel Generation** - Traditional exports list line items uniformly. This module groups the sales data by order. Order-level aggregates (such as *Total Charge*, *Subtotal*, *Tax*, *Paid Amount*, *Return*) are printed exclusively on the first row of each order's line items. - Subsequent line items for the same order only show item-specific details like *Product Name*, *SKU*, *Quantity*, and *Unit Price*, keeping the spreadsheet clean and highly readable. 2. **Automated "Invoice" and "Refund" Splitting** - The module automatically detects standard positive orders and negative return orders. - It separates them dynamically into two distinct sheets within the same workbook: **"Invoice"** (for orders with a total >= 0) and **"Refund"** (for orders with a total < 0). 3. **Custom "Dinein" vs "Takeaway" Logic** - Automatically determines if an order is for Dine-in or Takeaway based on the assigned POS table number. - If the assigned table number is `<= 60`, the system explicitly records it as `"dinein"`. - If the table number is `>= 61` (or if no table is assigned), the system automatically records it as `"takeaway"`. - Strips the display name to cleanly export just the actual integer Table Number. 4. **Integration with Odoo Studio Custom Fields** - Specifically configured to pull SKU values from a custom Odoo Studio product field (`x_studio_popcorn_sku`), seamlessly bridging standard Point of Sale code with codeless customizations. 5. **Precise Formatting and Value Handling** - Outputs datetime data (such as "Date" and "Paid At") as strict text strings (format: `DD-MM-YYYY HH:MM:SS`) to bypass Excel's aggressive, and often erroneous, timezone/date auto-formatting. - Correctly calculates the amount paid by only summing positive payment tenders and using standard POS change allocations for exact accounting matches. ## Requirements The module performs in-memory Excel generation rather than writing physical files, requiring the `xlsxwriter` library. Install it via your environment's package manager: ```sh pip install xlsxwriter ``` ## How to Use 1. **Install Module:** Navigate to the Odoo **Apps** menu and install `POS Export BC Format`. 2. **Open the Tool:** Go to the backend **Point of Sale** application. Click on **Reporting** in the top menu and select **Export BC Format**. 3. **Select Period:** A wizard window will prompt you for a **Start Date** and **End Date**. 4. **Generate:** Click the **Export to BC Format** button. 5. **Download:** A dynamically generated `.xlsx` file will automatically download to your browser. ## Technical Structure - **Models / Wizards**: Leverages an Odoo `TransientModel` (`pos.export.bc.wizard`) to prompt users for date ranges. - **Generation Logic**: The python script aggregates `pos.order` models matching the domain, then systematically writes rows into an `io.BytesIO` stream using the `xlsxwriter.Workbook`. - **Delivery**: The memory stream is temporarily saved to `ir.attachment` and served via a standard Odoo HTTP controller url act window (`/web/content/?download=true`).