odoo/tutorials#1325
Created by Aditi Pawar (adpaw)
Blocked
- Merge method
- Review
-
CI
- ci/style: (runtime 5s)
- ci/tutorial: (runtime 143s)
- label
- odoo-dev:19.0-new-product-type-adpaw
- head
- 4476196ae898fdfc7418ee23f245b84d21397462
| odoo/tutorials | |
|---|---|
| 19.0 | #1325 missing r+ |
| master |
[ADD] new_product_type: Implemented custom kit product without BOM dependency.
Introduce a new custom module that adds kit functionality to sale orders without requiring the Manufacturing module or Bill of Materials configuration.
WHY this change is being made:
Currently, Odoo only supports kit products through the mrp module which forces non-manufacturing businesses to install unnecessary components. This module bridges that gap by providing a lightweight kit mechanism directly within the sale module.
Technical decisions taken:
1. Created a standalone custom module inheriting from sale and product to maintain clean separation of custom business logic.
2. Added is_kit boolean and sub_product_ids Many2many on product.template with explicit relation table to avoid join table name collisions.
3. Used default_get to pre-populate wizard lines from sub_product_ids on first open and from existing sale.order.line records on reopen.
4. Used action_confirm_kit with write-or-create pattern to update existing sub-lines in place or create new ones, with total price recalculated as lst_price plus sum of component price times quantity written back to the parent line.
5. Implemented kit_main_line_id Many2one with ondelete cascade and api.ondelete guard to prevent direct sub-line deletion while allowing parent-triggered cascade.
6. Used QWeb template inheritance across sale order PDF, portal preview and invoice report to conditionally render kit components based on print_in_report toggle on sale.order.
Task ID: 4443261