Skip to content

Commit 0b83b38

Browse files
committed
adding custom routing functions
1 parent 064bf40 commit 0b83b38

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

erpnextswiss/erpnextswiss/common_functions.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import frappe
55
from frappe import _
66
from erpnextswiss.erpnextswiss.jinja import get_week_from_date
7-
from frappe.utils import cint
7+
from frappe.utils import cint, get_url_to_form, get_link_to_form, get_url_to_report, get_url_to_list, get_url_to_report_with_filters
88

99
# try to get building number from address line
1010
def get_building_number(address_line):
@@ -151,3 +151,23 @@ def get_recursive_item_groups(item_group):
151151
if c['name'] not in item_groups:
152152
item_groups.append(c['name'])
153153
return item_groups
154+
155+
@frappe.whitelist()
156+
def url_to_form(doctype, docname):
157+
return get_url_to_form(doctype, docname)
158+
159+
@frappe.whitelist()
160+
def link_to_form(doctype, docname):
161+
return get_link_to_form(doctype, docname)
162+
163+
@frappe.whitelist()
164+
def link_to_list(doctype):
165+
return get_link_to_list(doctype)
166+
167+
@frappe.whitelist()
168+
def url_to_report(name):
169+
return get_url_to_report(name)
170+
171+
@frappe.whitelist()
172+
def url_to_report_with_filters(name, filters, report_type=None, doctype=None):
173+
return get_url_to_report(name, fitlers, report_type, doctype)

erpnextswiss/public/js/swiss_common.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,58 @@ function fetch_price_list_rate(frm, cdt, cdn) {
233233
}
234234
});
235235
}
236+
237+
function url_to_form(doctype, docname, callback) {
238+
frappe.call({
239+
'method': 'erpnextswiss.erpnextswiss.common_functions.url_to_form',
240+
'args': {
241+
'doctype': doctype,
242+
'docname': docname
243+
}, // note: async: false is still not working, response would be undefined
244+
'callback': callback
245+
});
246+
}
247+
248+
function link_to_form(doctype, docname, callback) {
249+
frappe.call({
250+
'method': 'erpnextswiss.erpnextswiss.common_functions.link_to_form',
251+
'args': {
252+
'doctype': doctype,
253+
'docname': docname
254+
}, // note: async: false is still not working, response would be undefined
255+
'callback': callback
256+
});
257+
}
258+
259+
function url_to_list(doctype, callback) {
260+
frappe.call({
261+
'method': 'erpnextswiss.erpnextswiss.common_functions.url_to_list',
262+
'args': {
263+
'doctype': doctype
264+
}, // note: async: false is still not working, response would be undefined
265+
'callback': callback
266+
});
267+
}
268+
269+
function url_to_report(name, callback) {
270+
frappe.call({
271+
'method': 'erpnextswiss.erpnextswiss.common_functions.url_to_report',
272+
'args': {
273+
'name': name
274+
}, // note: async: false is still not working, response would be undefined
275+
'callback': callback
276+
});
277+
}
278+
279+
function url_to_report_with_filters(name, filters, report_type, doctype, callback) {
280+
frappe.call({
281+
'method': 'erpnextswiss.erpnextswiss.common_functions.url_to_report_with_filters',
282+
'args': {
283+
'name': name,
284+
'filters': filters,
285+
'report_type': report_type,
286+
'doctype': doctype
287+
}, // note: async: false is still not working, response would be undefined
288+
'callback': callback
289+
});
290+
}

0 commit comments

Comments
 (0)