From d324fdd8ea3b14c966510bde610a96c8f5c3e3c5 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 26 Sep 2023 14:56:35 +0700 Subject: Update readonly condition order line on purchase order --- indoteknik_custom/models/purchase_order.py | 5 +++++ indoteknik_custom/views/purchase_order.xml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index daf8d269..92df3119 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -46,6 +46,11 @@ class PurchaseOrder(models.Model): summary_qty_receipt = fields.Float('Summary Qty Receipt', compute='_compute_summary_qty') count_line_product = fields.Float('Total Item', compute='compute_count_line_product') note_description = fields.Char(string='Note', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') + has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice') + + def _compute_has_active_invoice(self): + for order in self: + order.has_active_invoice = any(invoice.state != 'cancel' for invoice in order.invoice_ids) def add_product_to_pricelist(self): for line in self.order_line: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index e7a72cd3..0ad76ae5 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -76,6 +76,11 @@ + + + + + {'readonly': ['|', ('state', 'in', ['done', 'cancel']), ('has_active_invoice', '=', True)]} -- cgit v1.2.3