From 11f0ee3cac7e9d4d1f163e84d4e1c5cbafac6eeb Mon Sep 17 00:00:00 2001 From: mbauskar Date: Fri, 9 Jun 2017 17:23:06 +0530 Subject: [PATCH] [docs] removed the globals from documentation --- .../custom-script-examples/date-validation.md | 4 ++-- .../restrict-cancel-rights.md | 6 +++--- .../restrict-purpose-of-stock-entry.md | 4 ++-- .../restrict-user-based-on-child-record.md | 13 ++++++------- .../custom-script-examples/date-validation.md | 4 ++-- .../restrict-cancel-rights.md | 6 +++--- .../restrict-purpose-of-stock-entry.md | 6 +++--- .../restrict-user-based-on-child-record.md | 8 ++++---- 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md index 5bd2901d85f..540d5cba8e9 100644 --- a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md +++ b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md @@ -3,8 +3,8 @@ frappe.ui.form.on("Event", "validate", function(frm) { if (frm.doc.from_date < get_today()) { - msgprint(__("You can not select past date in From Date")); - throw "past date selected" + frappe.msgprint(__("You can not select past date in From Date")); + frappe.throw(__("past date selected")) } }); diff --git a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md index d445a653ad2..9e5ab13f12a 100644 --- a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md +++ b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md @@ -4,12 +4,12 @@ Fügen Sie dem Ereignis custom_before_cancel eine Steuerungsfunktion hinzu: cur_frm.cscript.custom_before_cancel = function(doc) { - if (user_roles.indexOf("Accounts User")!=-1 && user_roles.indexOf("Accounts Manager")==-1 + if (frappe.user_roles.indexOf("Accounts User")!=-1 && frappe.user_roles.indexOf("Accounts Manager")==-1 && user_roles.indexOf("System Manager")==-1) { if (flt(doc.grand_total) > 10000) { - msgprint("You can not cancel this transaction, because grand total \ + frappe.msgprint("You can not cancel this transaction, because grand total \ is greater than 10000"); - validated = false; + frappe.validated = false; } } } diff --git a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md index bb925e13b18..a1cb769cce3 100644 --- a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md +++ b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md @@ -3,8 +3,8 @@ frappe.ui.form.on("Material Request", "validate", function(frm) { if(user=="user1@example.com" && frm.doc.purpose!="Material Receipt") { - msgprint("You are only allowed Material Receipt"); - throw "Not allowed"; + frappe.msgprint("You are only allowed Material Receipt"); + frappe.throw(__("Not allowed")); } } diff --git a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md index db725f284ae..652409f8bda 100644 --- a/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md +++ b/erpnext/docs/user/manual/de/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md @@ -3,17 +3,16 @@ // restrict certain warehouse to Material Manager cur_frm.cscript.custom_validate = function(doc) { - if(user_roles.indexOf("Material Manager")==-1) { - - var restricted_in_source = wn.model.get("Stock Entry Detail", + if(frappe.user_roles.indexOf("Material Manager")==-1) { + var restricted_in_source = frappe.model.get_list("Stock Entry Detail", {parent:cur_frm.doc.name, s_warehouse:"Restricted"}); - var restricted_in_target = wn.model.get("Stock Entry Detail", - {parent:cur_frm.doc.name, t_warehouse:"Restricted"}) + var restricted_in_target = frappe.model.get_list("Stock Entry Detail", + {parent:cur_frm.doc.name, t_warehouse:"Restricted"}); if(restricted_in_source.length || restricted_in_target.length) { - msgprint("Only Material Manager can make entry in Restricted Warehouse"); - validated = false; + frappe.msgprint(__("Only Material Manager can make entry in Restricted Warehouse")); + frappe.validated = false; } } } diff --git a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md index d68ab565f61..6e560cb66cd 100644 --- a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md +++ b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/date-validation.md @@ -3,8 +3,8 @@ frappe.ui.form.on("Task", "validate", function(frm) { if (frm.doc.from_date < get_today()) { - msgprint(__("You can not select past date in From Date")); - validated = false; + frappe.msgprint(__("You can not select past date in From Date")); + frappe.validated = false; } }); diff --git a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md index e5037fe135c..79fe9a5b070 100644 --- a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md +++ b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md @@ -3,12 +3,12 @@ Add a handler to `custom_before_cancel` event: cur_frm.cscript.custom_before_cancel = function(doc) { - if (user_roles.indexOf("Accounts User")!=-1 && user_roles.indexOf("Accounts Manager")==-1 + if (frappe.user_roles.indexOf("Accounts User")!=-1 && frappe.user_roles.indexOf("Accounts Manager")==-1 && user_roles.indexOf("System Manager")==-1) { if (flt(doc.grand_total) > 10000) { - msgprint("You can not cancel this transaction, because grand total \ + frappe.msgprint("You can not cancel this transaction, because grand total \ is greater than 10000"); - validated = false; + frappe.validated = false; } } } diff --git a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md index 9b37eb552d4..f3efd9813a2 100644 --- a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md +++ b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-purpose-of-stock-entry.md @@ -1,8 +1,8 @@ frappe.ui.form.on("Material Request", "validate", function(frm) { - if(user=="user1@example.com" && frm.doc.purpose!="Material Receipt") { - msgprint("You are only allowed Material Receipt"); - throw "Not allowed"; + if(frappe.user=="user1@example.com" && frm.doc.purpose!="Material Receipt") { + frappe.msgprint("You are only allowed Material Receipt"); + frappe.throw(__("Not allowed")); } } diff --git a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md index 6c36a144f72..849e68681af 100644 --- a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md +++ b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record.md @@ -1,16 +1,16 @@ // restrict certain warehouse to Material Manager cur_frm.cscript.custom_validate = function(doc) { - if(user_roles.indexOf("Material Manager")==-1) { + if(frappe.user_roles.indexOf("Material Manager")==-1) { - var restricted_in_source = wn.model.get("Stock Entry Detail", + var restricted_in_source = frappe.model.get_list("Stock Entry Detail", {parent:cur_frm.doc.name, s_warehouse:"Restricted"}); - var restricted_in_target = wn.model.get("Stock Entry Detail", + var restricted_in_target = frappe.model.get_list("Stock Entry Detail", {parent:cur_frm.doc.name, t_warehouse:"Restricted"}) if(restricted_in_source.length || restricted_in_target.length) { - msgprint("Only Material Manager can make entry in Restricted Warehouse"); + frappe.msgprint(__("Only Material Manager can make entry in Restricted Warehouse")); validated = false; } }