refactor: updated is_doc_status_readonly condition

This commit is contained in:
Shubh Doshi 2026-02-19 10:04:40 +05:30
parent 675b23c47c
commit 9dcc97cb26
2 changed files with 1 additions and 4 deletions

View file

@ -5,7 +5,7 @@ import { useStore } from "../store";
let store = useStore();
const is_doc_status_readonly = computed(() => {
if (!store.workflow.selected || !("state" in store.workflow.selected.data)) return false;
if (!store.workflow.selected || !(store.workflow.selected.type === "state")) return false;
return !store.is_submittable();
});
@ -37,7 +37,6 @@ let properties = computed(() => {
const submittable = store.is_submittable();
// Auto-reset doc_status to "Draft" for non-submittable doctypes
if (!submittable && store.workflow.selected.data.doc_status !== "Draft") {
store.workflow.selected.data.doc_status = "Draft";
}

View file

@ -90,11 +90,9 @@ class Workflow(Document):
frappe.throw(frappe._("{0} not a valid State").format(state))
# Check if doctype is submittable
meta = frappe.get_meta(self.document_type)
is_submittable = meta.is_submittable
# Validate that non-submittable doctypes only have doc_status 0
if not is_submittable:
for state in self.states:
if cint(state.doc_status or 0) != 0: