From bec7fb54936867f438bea60f42637089eedf9f8b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:32:58 +0530 Subject: [PATCH] fix(ux): make valuation field read only when it can't be modified (backport #38450) (#38463) * fix(ux): make `basic_rate` field read-only based on purpose (cherry picked from commit abc7d3002467946984be5b41d79024da92047dd3) * fix(ux): make PR `rate` field read-only having PO ref (cherry picked from commit ae294ee4702fa8e0367c07c881d632811beb67ae) # Conflicts: # erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json * fix(ux): make PI `rate` field read-only having PR ref (cherry picked from commit 3d4156cc7d90522f37f4c91e4ccf4145412109a9) * chore: `conflicts` --------- Co-authored-by: s-aga-r --- .../purchase_invoice_item/purchase_invoice_item.json | 3 ++- .../purchase_receipt_item/purchase_receipt_item.json | 3 ++- erpnext/stock/doctype/stock_entry/stock_entry.js | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index b62b4bab140..bc56132c60f 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -286,6 +286,7 @@ "oldfieldname": "import_rate", "oldfieldtype": "Currency", "options": "currency", + "read_only_depends_on": "eval: (!parent.is_return && doc.purchase_receipt && doc.pr_detail)", "reqd": 1 }, { @@ -893,7 +894,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2023-11-14 18:33:48.547297", + "modified": "2023-11-30 16:26:05.629780", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index 749dbf2111f..6d89e9897af 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -352,6 +352,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_width": "100px", + "read_only_depends_on": "eval: (!parent.is_return && doc.purchase_order && doc.purchase_order_item)", "width": "100px" }, { @@ -1054,7 +1055,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2023-11-14 18:38:15.251994", + "modified": "2023-11-30 16:12:02.364608", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 6dd0a58645c..70771e77461 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -241,7 +241,7 @@ frappe.ui.form.on('Stock Entry', { } } - if (frm.doc.docstatus===0) { + if (frm.doc.docstatus === 0) { frm.add_custom_button(__('Purchase Invoice'), function() { erpnext.utils.map_current_doc({ method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_stock_entry", @@ -294,7 +294,8 @@ frappe.ui.form.on('Stock Entry', { }) }, __("Get Items From")); } - if (frm.doc.docstatus===0 && frm.doc.purpose == "Material Issue") { + + if (frm.doc.docstatus === 0 && frm.doc.purpose == "Material Issue") { frm.add_custom_button(__('Expired Batches'), function() { frappe.call({ method: "erpnext.stock.doctype.stock_entry.stock_entry.get_expired_batch_items", @@ -379,6 +380,10 @@ frappe.ui.form.on('Stock Entry', { frm.remove_custom_button('Bill of Materials', "Get Items From"); frm.events.show_bom_custom_button(frm); frm.trigger('add_to_transit'); + + frm.fields_dict.items.grid.update_docfield_property( + 'basic_rate', 'read_only', frm.doc.purpose == "Material Receipt" ? 0 : 1 + ); }, purpose: function(frm) {