summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-06-11 09:33:19 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-06-11 09:33:19 +0700
commite989cf9dac14be220b746703f92aabbfd2d9022f (patch)
tree3709b8618ac43e288696d07d2845f32b1a0848f6
parent5be65f6f512124cb3b4c3b83d69f9ff86dc1c6b4 (diff)
product grouping
-rwxr-xr-xfixco_custom/models/detail_order.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py
index eeb9d00..57d5093 100755
--- a/fixco_custom/models/detail_order.py
+++ b/fixco_custom/models/detail_order.py
@@ -167,8 +167,28 @@ class DetailOrder(models.Model):
[('default_code', '=', item.get('masterSku'))],
limit=1
)
- # raise UserError(_("Product not found for SKU: %s") % item.get('sku'))
+
+ 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
+ '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'),
+ 'name': f"{bline.master_sku} (Bundle Component)" if bline.master_sku else product.name,
+ }))
+ continue # Skip proses normal untuk bundle
+
+ # Proses normal untuk non-bundle
line_data = {
'product_id': product.id if product else 5792,
'product_uom_qty': item.get('quantity'),
@@ -178,6 +198,7 @@ class DetailOrder(models.Model):
if not product:
line_data['name'] = f"{item.get('masterSku')} ({item.get('productName')})"
product_not_found = True
+
order_lines.append((0, 0, line_data))
return order_lines, product_not_found