diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-06-11 09:37:48 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-06-11 09:37:48 +0700 |
| commit | f4ff9e2abad82f07e039c388af5e82034ae30694 (patch) | |
| tree | 541d217d511f5cb671c6027438ae364341910bcd | |
| parent | e989cf9dac14be220b746703f92aabbfd2d9022f (diff) | |
product grouping
| -rwxr-xr-x | fixco_custom/models/detail_order.py | 11 | ||||
| -rwxr-xr-x | fixco_custom/models/product_product.py | 1 | ||||
| -rwxr-xr-x | fixco_custom/views/product_product.xml | 1 |
3 files changed, 6 insertions, 7 deletions
diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index 57d5093..e3370b0 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -169,26 +169,23 @@ class DetailOrder(models.Model): ) if product and item.get('masterSkuType') == 'BUNDLE': - # 1. Tambahkan notes sebagai line pertama order_lines.append((0, 0, { - 'display_type': 'line_note', # Untuk menandai sebagai notes + 'display_type': 'line_note', 'name': f"Bundle: {item.get('productName')}", 'product_uom_qty': 0, 'price_unit': 0, })) - # 2. Tambahkan komponen bundle bundling_lines = self.env['bundling.line'].search([('product_id', '=', product.id)]) for bline in bundling_lines: order_lines.append((0, 0, { 'product_id': bline.variant_id.id if bline.variant_id else product.id, - 'product_uom_qty': item.get('quantity'), - 'price_unit': bline.price if bline.price else item.get('actualPrice'), + 'product_uom_qty': bline.product_uom_qty * item.get('quantity') if bline.product_uom_qty else item.get('quantity'), + 'price_unit': bline.price * bline.product_uom_qty if bline.price else item.get('actualPrice'), 'name': f"{bline.master_sku} (Bundle Component)" if bline.master_sku else product.name, })) - continue # Skip proses normal untuk bundle + continue - # Proses normal untuk non-bundle line_data = { 'product_id': product.id if product else 5792, 'product_uom_qty': item.get('quantity'), diff --git a/fixco_custom/models/product_product.py b/fixco_custom/models/product_product.py index 719a183..bb3ba17 100755 --- a/fixco_custom/models/product_product.py +++ b/fixco_custom/models/product_product.py @@ -48,3 +48,4 @@ class BundlingLine(models.Model): variant_id = fields.Many2one('product.product', string="Variant") master_sku = fields.Char(string="Master SKU") price = fields.Float(string="Price") + product_uom_qty = fields.Float(string="Quantity") diff --git a/fixco_custom/views/product_product.xml b/fixco_custom/views/product_product.xml index cd065aa..7842909 100755 --- a/fixco_custom/views/product_product.xml +++ b/fixco_custom/views/product_product.xml @@ -25,6 +25,7 @@ <field name="arch" type="xml"> <tree editable="bottom"> <field name="variant_id" /> + <field name="product_uom_qty" /> <field name="master_sku" /> <field name="price"/> </tree> |
