Skip to content

Instantly share code, notes, and snippets.

View nathando's full-sized avatar
🎯
Focusing

Do Le Bao Nguyen nathando

🎯
Focusing
View GitHub Profile
@nathando
nathando / authenticated_api
Created July 9, 2014 10:21
Authenticated API
@frappe.whitelist(allow_guest=True)
@post_only
def login_test():
try:
frappe.local.login_manager.login()
full_name = frappe.response.pop("full_name")
# Return encrypted token
session_token = AESencrypt('password', str(frappe.local.session.get('sid')))
frappe.local.cookie_manager.set_cookie("sid", "")
return {"status": 1, "full_name": full_name, "s_token": session_token }
@nathando
nathando / sales_invoice.js
Last active August 29, 2015 14:01
Sales Invoice
cur_frm.cscript.custom_refresh = function(doc, dt, dn) {
var sales_invoice = locals[dt][dn];
var total_com = total_com_senior = 0;
cur_frm.set_value('sales_commission_value', -2);
wn.call({
method: "accounts.doctype.sales_invoice.sales_invoice.get_sale_commission",
args: {},
callback: function(r) {
console.log("Received value ", r); // Return {message:1"}
cur_frm.set_value('sales_commission_value', r.message);