| models/__pycache__ | ||
| security | ||
| wizard | ||
| __init__.py | ||
| __manifest__.py | ||
| .gitignore | ||
| README.md | ||
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
-
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.
-
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).
-
Custom "Dinein" vs "Takeaway" Logic & Naming Fallbacks
- Automatically determines if an order is for Dine-in or Takeaway based on whether a POS table is assigned.
- If a table is assigned, the system explicitly records it as
"dinein". - If no table is assigned, the system automatically records it as
"takeaway". - The Table/Customer column intelligently uses fallbacks: it prioritizes the exact table number (stripping the floor name), falls back to the floating order name (for takeaways), and finally falls back to the customer's name.
-
Integration with Odoo Studio Custom Fields
- Specifically configured to pull SKU values from a custom Odoo Studio product field (
x_studio_bc_item_id), seamlessly bridging standard Point of Sale code with codeless customizations.
- Specifically configured to pull SKU values from a custom Odoo Studio product field (
-
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.
- Computes an aggregate order-level Discount by intelligently scanning all lines in the order for negative prices and summing their pre-tax subtotals.
- Dynamically formats the Excel filename using the uppercase Company Registry, shortened dates (YYMMDD), and hard length-capping (max 40 characters) to meet tight system naming requirements (e.g.
POS_MMSBYSABRJ_260607_to_260608.xlsx).
- Outputs datetime data (such as "Date" and "Paid At") as strict text strings (format:
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:
pip install xlsxwriter
How to Use
- Install Module: Navigate to the Odoo Apps menu and install
POS Export BC Format. - Open the Tool: Go to the backend Point of Sale application. Click on Reporting in the top menu and select Export BC Format.
- Select Period: A wizard window will prompt you for a Start Date and End Date.
- Generate: Click the Export to BC Format button.
- Download: A dynamically generated
.xlsxfile 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.ordermodels matching the domain, then systematically writes rows into anio.BytesIOstream using thexlsxwriter.Workbook. - Delivery: The memory stream is temporarily saved to
ir.attachmentand served via a standard Odoo HTTP controller url act window (/web/content/<id>?download=true).