From db561aabfa404edfff9462c812d15a200223b978 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 8 Nov 2023 11:19:54 +0700 Subject: add responsible in po base on manufacture responsible --- indoteknik_custom/models/purchase_order.py | 9 +++++++++ indoteknik_custom/views/purchase_order.xml | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f9cd7f5b..b0f1a569 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -49,6 +49,15 @@ class PurchaseOrder(models.Model): has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice') description = fields.Char(string='Description', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') purchase_order_lines = fields.One2many('purchase.order.line', 'order_id', string='Indent', auto_join=True) + responsible_ids = fields.Many2many('res.users', string='Responsibles', compute='_compute_responsibles') + + def _compute_responsibles(self): + for purchase in self: + resposible_ids = [] + for line in purchase.order_line: + resposible_ids.append(line.product_id.x_manufacture.user_id.id) + resposible_ids = list(set(resposible_ids)) + purchase.responsible_ids = resposible_ids def _compute_has_active_invoice(self): for order in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 8f7ea6df..bc84bcd1 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -79,7 +79,7 @@ - + @@ -115,6 +115,7 @@ + @@ -130,6 +131,7 @@ + -- cgit v1.2.3