fix: add confirmation when updating counter and make document type mandatory
This commit is contained in:
parent
7ae60ff268
commit
71f45eba68
2 changed files with 21 additions and 2 deletions
|
|
@ -4,6 +4,24 @@
|
|||
frappe.ui.form.on("Document Naming Rule", {
|
||||
refresh: function (frm) {
|
||||
frm.trigger("document_type");
|
||||
frm.last_counter_value = frm.doc.counter;
|
||||
frm.skip_before_save = false;
|
||||
},
|
||||
before_save: function (frm) {
|
||||
if (frm.is_new() || frm.skip_before_save || frm.last_counter_value === frm.doc.counter)
|
||||
return;
|
||||
|
||||
frappe.validated = false;
|
||||
frappe.warn(
|
||||
__("Are you sure?"),
|
||||
__("Updating counter may lead to document name conflicts if not done properly"),
|
||||
() => {
|
||||
frm.skip_before_save = true;
|
||||
frm.save();
|
||||
},
|
||||
__("Proceed"),
|
||||
false
|
||||
);
|
||||
},
|
||||
document_type: (frm) => {
|
||||
// update the select field options with fieldnames
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@
|
|||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Document Type",
|
||||
"options": "DocType"
|
||||
"options": "DocType",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
|
|
@ -86,7 +87,7 @@
|
|||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-04-24 13:06:20.992011",
|
||||
"modified": "2023-04-24 15:14:32.054272",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Document Naming Rule",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue