diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-09-24 09:03:52 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-09-24 09:03:52 +0700 |
| commit | cc4be72fc2f0d98f8bc2190ea5c404536bb3c56d (patch) | |
| tree | a00f22741ba1ec63b59659834a9c6177b20db343 /indoteknik_custom/models/purchase_order.py | |
| parent | 1f9d0136758531831ea6c7a90556c9a472ed8d40 (diff) | |
| parent | 649f3037e4357dab42d1a8d799e5f2a2f1fd2e52 (diff) | |
Merge branch 'production' into unreserved_permission
# Conflicts:
# indoteknik_custom/models/sale_order.py
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..8a47482a 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', '=', purchase.id)], + ['margin_item'], + [] + ) + purchase.total_margin_match = result[0].get('margin_item', 0.0) def _compute_grand_total(self): for order in self: |
