diff --git a/frappe/model/workflow.py b/frappe/model/workflow.py index 0e345a651538..0d7ce13d953b 100644 --- a/frappe/model/workflow.py +++ b/frappe/model/workflow.py @@ -228,11 +228,7 @@ def send_email_alert(workflow_name): def get_workflow_field_value(workflow_name, field): - value = frappe.cache.hget("workflow_" + workflow_name, field) - if value is None: - value = frappe.db.get_value("Workflow", workflow_name, field) - frappe.cache.hset("workflow_" + workflow_name, field, value) - return value + return frappe.get_cached_value("Workflow", workflow_name, field) @frappe.whitelist() diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index d69a46d16bb7..8980a6d777ba 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -140,7 +140,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { this.workflow_action_items = {}; const actions = this.actions_menu_items.concat(this.workflow_action_menu_items); - actions.map((item) => { + actions.forEach((item) => { const $item = this.page.add_actions_menu_item(item.label, item.action, item.standard); if (item.class) { $item.addClass(item.class); @@ -549,7 +549,6 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (toggle) { this.page.show_actions_menu(); this.page.clear_primary_action(); - this.toggle_workflow_actions(); } else { this.page.hide_actions_menu(); this.set_primary_action(); @@ -597,7 +596,6 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { render() { this.render_list(); this.set_rows_as_checked(); - this.on_row_checked(); this.render_count(); } @@ -1318,6 +1316,11 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { this.update_checkbox($target); }); + + let me = this; + this.page.actions_btn_group.on("show.bs.dropdown", () => { + me.toggle_workflow_actions(); + }); } setup_like() { @@ -1673,6 +1676,8 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { get_workflow_action_menu_items() { const workflow_actions = []; + const me = this; + if (frappe.model.has_workflow(this.doctype)) { const actions = frappe.workflow.get_all_transition_actions(this.doctype); actions.forEach((action) => { @@ -1680,11 +1685,16 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { label: __(action), name: action, action: () => { - frappe.xcall("frappe.model.workflow.bulk_workflow_approval", { - docnames: this.get_checked_items(true), - doctype: this.doctype, - action: action, - }); + me.disable_list_update = true; + frappe + .xcall("frappe.model.workflow.bulk_workflow_approval", { + docnames: this.get_checked_items(true), + doctype: this.doctype, + action: action, + }) + .finally(() => { + me.disable_list_update = false; + }); }, is_workflow_action: true, }); @@ -1695,7 +1705,12 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { toggle_workflow_actions() { if (!frappe.model.has_workflow(this.doctype)) return; + + Object.keys(this.workflow_action_items).forEach((key) => { + this.workflow_action_items[key].addClass("disabled"); + }); const checked_items = this.get_checked_items(); + frappe .xcall("frappe.model.workflow.get_common_transition_actions", { docs: checked_items, @@ -1703,6 +1718,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { }) .then((actions) => { Object.keys(this.workflow_action_items).forEach((key) => { + this.workflow_action_items[key].removeClass("disabled"); this.workflow_action_items[key].toggle(actions.includes(key)); }); }); diff --git a/frappe/workflow/doctype/workflow/workflow.json b/frappe/workflow/doctype/workflow/workflow.json index 4b945a33c220..bddf8a66d79d 100644 --- a/frappe/workflow/doctype/workflow/workflow.json +++ b/frappe/workflow/doctype/workflow/workflow.json @@ -54,7 +54,7 @@ "label": "Don't Override Status" }, { - "default": "1", + "default": "0", "description": "Emails will be sent with next possible workflow actions", "fieldname": "send_email_alert", "fieldtype": "Check", diff --git a/frappe/workflow/doctype/workflow/workflow.py b/frappe/workflow/doctype/workflow/workflow.py index 56c17261b7ce..c28d5e4cd9fa 100644 --- a/frappe/workflow/doctype/workflow/workflow.py +++ b/frappe/workflow/doctype/workflow/workflow.py @@ -17,7 +17,6 @@ def validate(self): def on_update(self): self.update_doc_status() frappe.clear_cache(doctype=self.document_type) - frappe.cache.delete_key("workflow_" + self.name) # clear cache created in model/workflow.py def create_custom_field_for_workflow_state(self): frappe.clear_cache(doctype=self.document_type)