Skip to content

Commit

Permalink
fix(healthcare service unit):Tree view add_node and related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gokul1407 committed Aug 6, 2024
1 parent 14ff9cb commit 02f80da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ frappe.ui.form.on('Healthcare Service Unit', {
set_root_readonly: function(frm) {
// read-only for root healthcare service unit
frm.set_intro('');
if (!frm.doc.parent_healthcare_service_unit) {
if (!frm.is_new() && !frm.doc.parent_healthcare_service_unit) {
frm.set_read_only();
frm.set_intro(__('This is a root healthcare service unit and cannot be edited.'), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ frappe.treeview_settings['Healthcare Service Unit'] = {
title: __('Service Unit Tree'),
get_tree_root: false,
get_tree_nodes: 'healthcare.healthcare.utils.get_children',
add_tree_node: 'healthcare.healthcare.utils.add_node',
filters: [{
fieldname: 'company',
fieldtype: 'Select',
Expand Down
13 changes: 12 additions & 1 deletion healthcare/healthcare/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import frappe
from frappe import _
from frappe.utils import cstr, flt, get_link_to_form, rounded, time_diff_in_hours
from frappe.utils import cint, cstr, flt, get_link_to_form, rounded, time_diff_in_hours
from frappe.utils.formatters import format_value

from erpnext.setup.utils import insert_record
Expand Down Expand Up @@ -1327,3 +1327,14 @@ def generate_barcodes(in_val):
stream.close()

return barcode_base64

@frappe.whitelist()
def add_node():
from frappe.desk.treeview import make_tree_args

args = make_tree_args(**frappe.form_dict)

if cint(args.is_root):
args.parent_healthcare_service_unit = None

frappe.get_doc(args).insert()

0 comments on commit 02f80da

Please sign in to comment.