summaryrefslogtreecommitdiff
path: root/fixco_custom
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-06-20 10:20:35 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-06-20 10:20:35 +0700
commit361b171b83e3baed2ba240ace756bb73f1557d2a (patch)
treeaf2d4a72f46775f9f08a7a599fa06879a3e39394 /fixco_custom
parent03298bc537ff3e29c6925f640ca0a1106a569bd5 (diff)
prorate sales price
Diffstat (limited to 'fixco_custom')
-rwxr-xr-xfixco_custom/models/detail_order.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py
index b2f7625..e2cb5cb 100755
--- a/fixco_custom/models/detail_order.py
+++ b/fixco_custom/models/detail_order.py
@@ -178,11 +178,17 @@ class DetailOrder(models.Model):
}))
bundling_lines = self.env['bundling.line'].search([('product_id', '=', product.id)])
+ bundling_variant_ids = bundling_lines.mapped('variant_id').ids
+ sale_pricelist = self.env['sale.pricelist'].search([('product_id', 'in', bundling_variant_ids)])
+ price_bundling_bottom = sum(item.price for item in sale_pricelist)
for bline in bundling_lines:
+ bottom_price = self.env['sale.pricelist'].search([('product_id', '=', bline.variant_id.id)], limit=1)
+ price = bottom_price.price
+ price_unit = self.prorate_price_bundling(bline.variant_id,price_bundling_bottom,price,actual_price=item.get('actualPrice'))
order_lines.append((0, 0, {
'product_id': bline.variant_id.id if bline.variant_id else product.id,
'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'),
+ 'price_unit': price_unit,
'name': f"{bline.variant_id.display_name} (Bundle Component)" if bline.variant_id.display_name else product.name,
}))
@@ -282,6 +288,12 @@ class DetailOrder(models.Model):
).decode('ascii')
return authorization
+ def prorate_price_bundling(self, product, sum_bottom, price_bottom,actual_price):
+ percent = price_bottom / sum_bottom
+ real_price = percent * actual_price
+
+ return real_price
+
# check print do section