@@ -40,47 +40,49 @@ function custom_print_button(frm) {
4040 if ( frm . doc . docstatus != 1 ) {
4141 return
4242 }
43- frappe . db . get_value ( 'BEAM Settings' , { company : frm . doc . company } , 'enable_handling_units' , r => {
44- if ( r && r . enable_handling_units ) {
45- frm . add_custom_button ( __ ( '<span class="fa fa-print"></span> Print Handling Unit' ) , ( ) => {
46- let d = new frappe . ui . Dialog ( {
47- title : __ ( 'Select Printer Setting' ) ,
48- fields : [
49- {
50- label : __ ( 'Printer Setting' ) ,
51- fieldname : 'printer_setting' ,
52- fieldtype : 'Link' ,
53- options : 'Network Printer Settings' ,
54- } ,
55- {
56- label : __ ( 'Printer Format' ) ,
57- fieldname : 'print_format' ,
58- fieldtype : 'Link' ,
59- options : 'Print Format' ,
60- get_query : function ( ) {
61- return {
62- filters : { doc_type : 'Handling Unit' } ,
63- }
64- } ,
65- } ,
66- ] ,
67- primary_action_label : 'Select' ,
68- primary_action ( selection ) {
69- d . hide ( )
70- frappe . call ( {
71- method : 'beam.beam.printing.print_handling_units' ,
72- args : {
73- doctype : frm . doc . doctype ,
74- name : frm . doc . name ,
75- printer_setting : selection . printer_setting ,
76- print_format : selection . print_format ,
77- doc : frm . doc ,
78- } ,
79- } )
43+ const beam_settings = frappe . boot . beam ?. settings ?. [ frm . doc . company ]
44+ if ( ! beam_settings ?. enable_handling_units ) {
45+ return
46+ }
47+ frm . add_custom_button ( __ ( '<span class="fa fa-print"></span> Print Handling Unit' ) , ( ) => {
48+ let d = new frappe . ui . Dialog ( {
49+ title : __ ( 'Select Printer Setting' ) ,
50+ fields : [
51+ {
52+ label : __ ( 'Printer Setting' ) ,
53+ fieldname : 'printer_setting' ,
54+ fieldtype : 'Link' ,
55+ options : 'Network Printer Settings' ,
56+ default : frappe . defaults . get_user_default ( 'Network Printer Settings' ) ,
57+ } ,
58+ {
59+ label : __ ( 'Print Format' ) ,
60+ fieldname : 'print_format' ,
61+ fieldtype : 'Link' ,
62+ options : 'Print Format' ,
63+ default : frappe . boot . beam ?. default_hu_print_format ,
64+ get_query : function ( ) {
65+ return {
66+ filters : { doc_type : 'Handling Unit' } ,
67+ }
68+ } ,
69+ } ,
70+ ] ,
71+ primary_action_label : 'Select' ,
72+ primary_action ( selection ) {
73+ d . hide ( )
74+ frappe . call ( {
75+ method : 'beam.beam.printing.print_handling_units' ,
76+ args : {
77+ doctype : frm . doc . doctype ,
78+ name : frm . doc . name ,
79+ printer_setting : selection . printer_setting ,
80+ print_format : selection . print_format ,
81+ doc : frm . doc ,
8082 } ,
8183 } )
82- d . show ( )
83- } )
84- }
84+ } ,
85+ } )
86+ d . show ( )
8587 } )
8688}
0 commit comments