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.py | |
| parent | 9d28e451949bef17c40b1a188d4d744c17715925 (diff) | |
| parent | a37bc839612b5162b4446182ac23c1dfd1c3253e (diff) | |
Merge branch 'feature/margin-deduct-purchase-delivery' into production
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index edcbbb19..afa67cf2 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -69,6 +69,17 @@ class PurchaseOrder(models.Model): date_done_picking = fields.Datetime(string='Date Done Picking', compute='get_date_done') bills_dp_id = fields.Many2one('account.move', string='Bills DP') grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') + total_margin_match = fields.Float(string='Total Margin Match', compute='_compute_total_margin_match') + + def _compute_total_margin_match(self): + for purchase in self: + match = self.env['purchase.order.sales.match'] + result = match.read_group( + [('purchase_order_id.id', '=', purchase.id)], + ['margin_item'], + [] + ) + purchase.total_margin_match = result[0].get('margin_item', 0.0) def _compute_grand_total(self): for order in self: |
