summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order_line.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/purchase_order_line.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index 19c2c8fa..bd758055 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -17,6 +17,7 @@ class PurchaseOrderLine(models.Model):
so_item_percent_margin = fields.Float(
'SO Margin%', compute='compute_item_margin',
help="Total % Margin in Sales Order Header")
+ delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line')
# Override method from addons/purchase/models/purchase.py
@api.onchange('product_qty', 'product_uom')
@@ -56,13 +57,22 @@ class PurchaseOrderLine(models.Model):
sum_so_margin += sale_order_line.item_margin
sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty
if sale_order_line.order_id.shipping_cost_covered == 'indoteknik':
- sales_price -= round((sale_order_line.order_id.delivery_amt / sale_order_line.order_id.count_line_product), 2)
+ sales_price -= sale_order_line.delivery_amt_line
sum_sales_price += sales_price
purchase_price = line.price_subtotal
if line.order_id.delivery_amount > 0:
- purchase_price += round((line.order_id.delivery_amount / line.order_id.count_line_product), 2)
+ purchase_price += line.delivery_amt_line
real_item_margin = sales_price - purchase_price
real_item_percent_margin = round((real_item_margin/sales_price), 2) * 100
line.item_margin = real_item_margin
line.item_percent_margin = real_item_percent_margin
sum_margin += real_item_margin
+
+ def compute_delivery_amt_line(self):
+ for line in self:
+ if line.product_id.type == 'product':
+ contribution = round((line.price_total / line.order_id.amount_total_without_service), 2)
+ delivery_amt = line.order_id.delivery_amount
+ line.delivery_amt_line = delivery_amt * contribution
+ else:
+ line.delivery_amt_line = 0