diff --git a/README.md b/README.md index 37bb738..133aeec 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,45 @@ -Purchase Export BC Module -This plan covers the implementation of the "export PO to BC Format" feature for Odoo 19, added as a custom module. +# Purchase Export BC Format -purchase_export_bc (New Module) -Module Structure: -- init.py and manifest.py: Describe the new module and its dependency on purchase. -- models/__init__.py and models/purchase_order.py: Extend the purchase.order model by adding the "action_export_bc" method. This method will filter order_line, group them by the product's category name (product_id.categ_id.name), create a new sheet per category, evaluate x_studio_bc_item_id and the units/packaging, generate the Excel document using xlsxwriter, and return an ir.actions.act_url to download it. -- views/purchase_order_views.xml: Extend purchase.view_purchase_order_form to inject a new button "action_export_bc" into the existing
. +**Purchase Export BC Format** is a custom Odoo 19 module that provides functionality to export a Purchase Order's details into an Excel (`.xlsx`) format. -Verification Plan -Manual Verification -1. Access Odoo -> App -> Update App List and install the new "Purchase Export BC Format" module. -2. Go to the Purchase application and open an existing Purchase Order. -3. Click the new button "Export PO to BC Format" in the header. -4. Verify an Excel file is downloaded. -5. Open the Excel file and verify: - - There is one sheet per item category. - - The headers are: "Type", "Item No.", "Description", "Qty", "Satuan". - - The "Type" column has the static value "Item". - - "Qty" perfectly matches the ordered quantity. - - The packaging name and product categories map properly. \ No newline at end of file +## Features + +- **One-Click Export**: Adds an "Export PO to BC Format" button directly inside the header of the Purchase Order form view (visible in the `purchase` or `done` states). +- **Automated Categorization**: Groups the purchase order lines by their Product Category. For each category, a dedicated worksheet is created in the generated Excel file. +- **Custom Data Mapping**: Fetches specific product data, such as a custom field `x_studio_bc_item_id` for custom Item Numbers. +- **Unit of Measure Handling**: Intelligently determines the "Satuan" (Unit), favoring the Product Packaging if defined, and otherwise falling back to the standard Unit of Measure (`product_uom_id`). + +## Excel File Structure + +For each generated worksheet (named after the product category), the layout is strictly mapped according to the requested BC format: + +| Column Header | Data Source / Description | +|---|---| +| **Type** | Static value `Item`. | +| **Item No.** | The value from the product's custom field `x_studio_bc_item_id`. | +| **Description** | The Product's name. | +| **Qty** | The ordered quantity. | +| **Satuan** | The Packaging used (if any). If none, it uses the product's Unit of Measure name. | + +## Installation + +1. Place the `purchase_export_bc` module directory into your Odoo 19 `custom` addons path. +2. Restart the Odoo server. +3. Turn on **Developer Mode** in Odoo. +4. Go to **Apps** -> **Update Apps List**. +5. Search for `Purchase Export BC Format` and click **Activate**. +6. **Requirement**: Ensure that the Python library `xlsxwriter` is installed in your Odoo environment: + ```bash + pip install xlsxwriter + ``` + +## Usage + +1. Navigate to the **Purchase** app in Odoo. +2. Open any existing Purchase Order that is confirmed. +3. Click the **Export PO to BC Format** button located in the header. +4. The system will automatically generate and prompt you to download the Excel file named `PO_Export_BC_[Order_Name].xlsx`. + +## Author + +- Aziz