summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order_sales_match.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/purchase_order_sales_match.py')
-rw-r--r--indoteknik_custom/models/purchase_order_sales_match.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py
index 78581409..d1d929d3 100644
--- a/indoteknik_custom/models/purchase_order_sales_match.py
+++ b/indoteknik_custom/models/purchase_order_sales_match.py
@@ -20,7 +20,17 @@ class PurchaseOrderSalesMatch(models.Model):
product_id = fields.Many2one('product.product', string='Product')
qty_so = fields.Float(string='Qty SO')
qty_po = fields.Float(string='Qty PO')
- margin_so = fields.Float(string='Margin SO')
+ margin_so = fields.Float(string='Margin SO')
+ margin_item = fields.Float(string='Margin')
+ delivery_amt = fields.Float(string='Delivery Amount', compute='_compute_delivery_amt')
+ margin_deduct = fields.Float(string='After Deduct', compute='_compute_delivery_amt')
+
+ def _compute_delivery_amt(self):
+ for line in self:
+ percent_margin = line.margin_item / line.purchase_order_id.total_margin_match \
+ if line.purchase_order_id.total_margin_match else 0
+ line.delivery_amt = line.purchase_order_id.delivery_amt * percent_margin
+ line.margin_deduct = line.margin_item - line.delivery_amt
@api.onchange('sale_id')
def onchange_sale_id(self):