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/automatic_purchase.py | |
| parent | 9d28e451949bef17c40b1a188d4d744c17715925 (diff) | |
| parent | a37bc839612b5162b4446182ac23c1dfd1c3253e (diff) | |
Merge branch 'feature/margin-deduct-purchase-delivery' into production
Diffstat (limited to 'indoteknik_custom/models/automatic_purchase.py')
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 13c83b04..548115e6 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -293,6 +293,9 @@ class AutomaticPurchase(models.Model): sale_ids_set.add(sale_id_with_salesperson) sale_ids_name.add(sale_order.sale_id.name) + margin_item = sale_order.sale_line_id.item_margin / sale_order.qty_so if sale_order.qty_so else 0 + margin_item = margin_item * sale_order.qty_po + matches_so_line = { 'purchase_order_id': purchase_order.id, 'sale_id': sale_order.sale_id.id, @@ -305,7 +308,8 @@ class AutomaticPurchase(models.Model): 'product_id': sale_order.product_id.id, 'qty_so': sale_order.qty_so, 'qty_po': sale_order.qty_po, - 'margin_so': sale_order.sale_line_id.item_percent_margin + 'margin_so': sale_order.sale_line_id.item_percent_margin, + 'margin_item': margin_item } po_matches_so_line = self.env['purchase.order.sales.match'].create([matches_so_line]) |
