fix: disable/enable with button

This commit is contained in:
Ankush Menat 2023-05-29 13:03:34 +05:30
parent 40ce33dff1
commit 81e901ba62
2 changed files with 10 additions and 4 deletions

View File

@ -42,6 +42,12 @@ frappe.ui.form.on("Warehouse", {
if (!frm.is_new()) { if (!frm.is_new()) {
frappe.contacts.render_address_and_contact(frm); frappe.contacts.render_address_and_contact(frm);
let enable_toggle = frm.doc.disabled ? "Enable" : "Disable";
frm.add_custom_button(__(enable_toggle), () => {
frm.set_value('disabled', 1 - frm.doc.disabled);
frm.save()
});
frm.add_custom_button(__("Stock Balance"), function () { frm.add_custom_button(__("Stock Balance"), function () {
frappe.set_route("query-report", "Stock Balance", { frappe.set_route("query-report", "Stock Balance", {
warehouse: frm.doc.name, warehouse: frm.doc.name,

View File

@ -1,7 +1,7 @@
{ {
"actions": [], "actions": [],
"allow_import": 1, "allow_import": 1,
"creation": "2013-03-07 18:50:32", "creation": "2023-05-29 13:02:17.121296",
"description": "A logical Warehouse against which stock entries are made.", "description": "A logical Warehouse against which stock entries are made.",
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
@ -80,7 +80,7 @@
"default": "0", "default": "0",
"fieldname": "disabled", "fieldname": "disabled",
"fieldtype": "Check", "fieldtype": "Check",
"in_list_view": 1, "hidden": 1,
"label": "Disabled" "label": "Disabled"
}, },
{ {
@ -166,7 +166,6 @@
{ {
"fieldname": "city", "fieldname": "city",
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1,
"label": "City", "label": "City",
"oldfieldname": "city", "oldfieldname": "city",
"oldfieldtype": "Data" "oldfieldtype": "Data"
@ -242,6 +241,7 @@
"options": "Warehouse" "options": "Warehouse"
}, },
{ {
"collapsible": 1,
"fieldname": "transit_section", "fieldname": "transit_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Transit" "label": "Transit"
@ -255,7 +255,7 @@
"idx": 1, "idx": 1,
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2023-05-29 12:59:48.371803", "modified": "2023-05-29 13:07:38.666681",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Warehouse", "name": "Warehouse",