summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-15 11:52:33 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-15 11:52:33 +0700
commit0198b0a0683cc7db1241ec9b7184c2cb608ba049 (patch)
tree0c1b46a12fe1960eb9c8f577877b7d92d1a138f3
parent7f4510f2459e16b7b3f1828f736ec84bc7ea97dc (diff)
(andri) fix edit unit price PO
-rwxr-xr-xindoteknik_custom/models/purchase_order.py9
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml2
2 files changed, 9 insertions, 2 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 4dc26d74..6901ecb6 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -668,9 +668,16 @@ class PurchaseOrder(models.Model):
resposible_ids = list(set(resposible_ids))
purchase.responsible_ids = resposible_ids
+ # 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 _compute_has_active_invoice(self):
for order in self:
- order.has_active_invoice = any(invoice.state != 'cancel' for invoice in order.invoice_ids)
+ related_invoices = order.invoice_ids.filtered(
+ lambda inv: inv.purchase_order_id.id == order.id and inv.move_type == 'in_invoice' and inv.state != 'cancel'
+ )
+ order.has_active_invoice = bool(related_invoices)
def add_product_to_pricelist(self):
i = 0
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index dae23eed..fa8d40d5 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -164,7 +164,7 @@
</field>
<field name="order_line" position="attributes">
- <attribute name="attrs">{'readonly': ['|', ('state', 'in', ['purchase', 'done', 'cancel']), ('has_active_invoice', '=', True)]}</attribute>
+ <attribute name="attrs">{'readonly': ['&amp;', ('state', 'in', ['purchase', 'done', 'cancel']), ('has_active_invoice', '=', True)]}</attribute>
</field>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit']" position="attributes">