diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-09-12 14:18:26 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-09-12 14:18:26 +0700 |
| commit | bd29d3fb44f693e950236b67b6a9a6ce64690505 (patch) | |
| tree | 3080d45fc81475f4f97d949f8b904345e7ab692a /indoteknik_custom/models/purchase_order_sales_match.py | |
| parent | 9d28e451949bef17c40b1a188d4d744c17715925 (diff) | |
| parent | a37bc839612b5162b4446182ac23c1dfd1c3253e (diff) | |
Merge branch 'feature/margin-deduct-purchase-delivery' into production
Diffstat (limited to 'indoteknik_custom/models/purchase_order_sales_match.py')
| -rw-r--r-- | indoteknik_custom/models/purchase_order_sales_match.py | 12 |
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): |
