diff --git a/README.md b/README.md index 2b7119cfd96..749ddd82f16 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Built on Python / MySQL. -ERPNext is built on [wnframework](https://github.com/webnotes/wnframework) +ERPNext is built on [frappe](https://github.com/frappe/frappe) - [User Guide](http://erpnext.org/user-guide.html) - [Getting Help](http://erpnext.org/getting-help.html) @@ -24,10 +24,10 @@ ERPNext is built on [wnframework](https://github.com/webnotes/wnframework) 1. Switch to root user using `sudo su` 1. create a folder where you want to install erpnext 1. go to the new folder -1. `wget https://raw.github.com/webnotes/erpnext/master/install_erpnext.py` +1. `wget https://raw.github.com/frappe/erpnext/master/install_erpnext.py` 1. `python install_erpnext.py` -[See installation notes](https://github.com/webnotes/erpnext/wiki/How-to-Install-ERPNext) +[See installation notes](https://github.com/frappe/erpnext/wiki/How-to-Install-ERPNext) ##### Patch and update diff --git a/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt b/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt index 761be67b0ca..4f20ac245b2 100644 --- a/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt +++ b/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt @@ -9,7 +9,7 @@ { "doc_type": "Sales Invoice", "doctype": "Print Format", - "html": "\n\t
\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n", + "html": "\n\t\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n", "module": "Accounts", "name": "__common__", "print_format_type": "Client", diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt index 3dcf7f27e14..5bf9bf32031 100644 --- a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt +++ b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt @@ -9,7 +9,7 @@ { "doc_type": "Sales Invoice", "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n
| \n\t\t\t\t
| \n\t\t\t
| \n\t\t\t\t
| \n\t\t\t
| \n\t\t\t\t
| \n\t\t\t||||||||||||||
| \n\t\t\t\t
| \n\t\t\t||||||||||||||
| \n\t\t\t\t
| \n\t\t\t||||||||||||
| \n\t\t\t\t
| \n\t\t\t||||||||||||
'+wn._('Note:')+''+ wn._('This Cost Center is a')+ ''+wn._('Group')+', '+ - wn._('Accounting Entries are not allowed against groups.')+'
'; + intro_txt += ''+frappe._('Note:')+''+ frappe._('This Cost Center is a')+ ''+frappe._('Group')+', '+ + frappe._('Accounting Entries are not allowed against groups.')+'
'; } cur_frm.cscript.hide_unhide_group_ledger(doc); @@ -50,22 +50,22 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger') cur_frm.set_intro(intro_txt); - cur_frm.appframe.add_button(wn._('Chart of Cost Centers'), - function() { wn.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap') + cur_frm.appframe.add_button(frappe._('Chart of Cost Centers'), + function() { frappe.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap') } cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) { if(!doc.company){ - msgprint(wn._('Please enter company name first')); + msgprint(frappe._('Please enter company name first')); } } cur_frm.cscript.hide_unhide_group_ledger = function(doc) { if (cstr(doc.group_or_ledger) == 'Group') { - cur_frm.add_custom_button(wn._('Convert to Ledger'), + cur_frm.add_custom_button(frappe._('Convert to Ledger'), function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet') } else if (cstr(doc.group_or_ledger) == 'Ledger') { - cur_frm.add_custom_button(wn._('Convert to Group'), + cur_frm.add_custom_button(frappe._('Convert to Group'), function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet') } } diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index 0d38cc820c8..666503964ad 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -2,11 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes -from webnotes.model.bean import getlist -from webnotes import msgprint, _ +import frappe +from frappe.model.bean import getlist +from frappe import msgprint, _ -from webnotes.utils.nestedset import DocTypeNestedSet +from frappe.utils.nestedset import DocTypeNestedSet class DocType(DocTypeNestedSet): def __init__(self,d,dl): @@ -14,7 +14,7 @@ class DocType(DocTypeNestedSet): self.nsm_parent_field = 'parent_cost_center' def autoname(self): - company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", + company_abbr = frappe.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0] self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr @@ -46,10 +46,10 @@ class DocType(DocTypeNestedSet): return 1 def check_gle_exists(self): - return webnotes.conn.get_value("GL Entry", {"cost_center": self.doc.name}) + return frappe.conn.get_value("GL Entry", {"cost_center": self.doc.name}) def check_if_child_exists(self): - return webnotes.conn.sql("select name from `tabCost Center` where \ + return frappe.conn.sql("select name from `tabCost Center` where \ parent_cost_center = %s and docstatus != 2", self.doc.name) def validate_budget_details(self): @@ -67,7 +67,7 @@ class DocType(DocTypeNestedSet): """ Cost Center name must be unique """ - if (self.doc.fields.get("__islocal") or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)): + if (self.doc.fields.get("__islocal") or not self.doc.name) and frappe.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)): msgprint("Cost Center Name already exists, please rename", raise_exception=1) self.validate_mandatory() @@ -85,7 +85,7 @@ class DocType(DocTypeNestedSet): def after_rename(self, olddn, newdn, merge=False): if not merge: - webnotes.conn.set_value("Cost Center", newdn, "cost_center_name", + frappe.conn.set_value("Cost Center", newdn, "cost_center_name", " - ".join(newdn.split(" - ")[:-1])) else: super(DocType, self).after_rename(olddn, newdn, merge) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js index 6bf712937ac..6aa5ae8883f 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js @@ -8,12 +8,12 @@ $.extend(cur_frm.cscript, { this.frm.toggle_enable('year_end_date', doc.__islocal) if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) { - this.frm.add_custom_button(wn._("Set as Default"), this.frm.cscript.set_as_default); - this.frm.set_intro(wn._("To set this Fiscal Year as Default, click on 'Set as Default'")); + this.frm.add_custom_button(frappe._("Set as Default"), this.frm.cscript.set_as_default); + this.frm.set_intro(frappe._("To set this Fiscal Year as Default, click on 'Set as Default'")); } else this.frm.set_intro(""); }, set_as_default: function() { - return wn.call({ + return frappe.call({ doc: cur_frm.doc, method: "set_as_default" }); @@ -22,7 +22,7 @@ $.extend(cur_frm.cscript, { var me = this; year_end_date = - wn.datetime.add_days(wn.datetime.add_months(this.frm.doc.year_start_date, 12), -1); + frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1); this.frm.set_value("year_end_date", year_end_date); }, }); \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index a09e9731bc2..381acf3d9a4 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -2,44 +2,44 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes -from webnotes import msgprint, _ -from webnotes.utils import getdate +import frappe +from frappe import msgprint, _ +from frappe.utils import getdate class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl def set_as_default(self): - webnotes.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name) - webnotes.get_obj("Global Defaults").on_update() + frappe.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name) + frappe.get_obj("Global Defaults").on_update() # clear cache - webnotes.clear_cache() + frappe.clear_cache() msgprint(self.doc.name + _(""" is now the default Fiscal Year. \ Please refresh your browser for the change to take effect.""")) def validate(self): - year_start_end_dates = webnotes.conn.sql("""select year_start_date, year_end_date + year_start_end_dates = frappe.conn.sql("""select year_start_date, year_end_date from `tabFiscal Year` where name=%s""", (self.doc.name)) if year_start_end_dates: if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]: - webnotes.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved.")) + frappe.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved.")) def on_update(self): # validate year start date and year end date if getdate(self.doc.year_start_date) > getdate(self.doc.year_end_date): - webnotes.throw(_("Year Start Date should not be greater than Year End Date")) + frappe.throw(_("Year Start Date should not be greater than Year End Date")) if (getdate(self.doc.year_end_date) - getdate(self.doc.year_start_date)).days > 366: - webnotes.throw(_("Year Start Date and Year End Date are not within Fiscal Year.")) + frappe.throw(_("Year Start Date and Year End Date are not within Fiscal Year.")) - year_start_end_dates = webnotes.conn.sql("""select name, year_start_date, year_end_date + year_start_end_dates = frappe.conn.sql("""select name, year_start_date, year_end_date from `tabFiscal Year` where name!=%s""", (self.doc.name)) for fiscal_year, ysd, yed in year_start_end_dates: if (getdate(self.doc.year_start_date) == ysd and getdate(self.doc.year_end_date) == yed) \ - and (not webnotes.flags.in_test): - webnotes.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year) \ No newline at end of file + and (not frappe.flags.in_test): + frappe.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year) \ No newline at end of file diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 20cd8993bf6..e3eff9b0ccb 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -2,10 +2,10 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe -from webnotes.utils import flt, fmt_money, getdate -from webnotes import _ +from frappe.utils import flt, fmt_money, getdate +from frappe import _ class DocType: def __init__(self,d,dl): @@ -34,17 +34,17 @@ class DocType: mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company'] for k in mandatory: if not self.doc.fields.get(k): - webnotes.throw(k + _(" is mandatory for GL Entry")) + frappe.throw(k + _(" is mandatory for GL Entry")) # Zero value transaction is not allowed if not (flt(self.doc.debit) or flt(self.doc.credit)): - webnotes.throw(_("GL Entry: Debit or Credit amount is mandatory for ") + + frappe.throw(_("GL Entry: Debit or Credit amount is mandatory for ") + self.doc.account) def pl_must_have_cost_center(self): - if webnotes.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes": + if frappe.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes": if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher': - webnotes.throw(_("Cost Center must be specified for PL Account: ") + + frappe.throw(_("Cost Center must be specified for PL Account: ") + self.doc.account) elif self.doc.cost_center: self.doc.cost_center = None @@ -55,23 +55,23 @@ class DocType: def check_pl_account(self): if self.doc.is_opening=='Yes' and \ - webnotes.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes": - webnotes.throw(_("For opening balance entry account can not be a PL account")) + frappe.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes": + frappe.throw(_("For opening balance entry account can not be a PL account")) def validate_account_details(self, adv_adj): """Account must be ledger, active and not freezed""" - ret = webnotes.conn.sql("""select group_or_ledger, docstatus, company + ret = frappe.conn.sql("""select group_or_ledger, docstatus, company from tabAccount where name=%s""", self.doc.account, as_dict=1)[0] if ret.group_or_ledger=='Group': - webnotes.throw(_("Account") + ": " + self.doc.account + _(" is not a ledger")) + frappe.throw(_("Account") + ": " + self.doc.account + _(" is not a ledger")) if ret.docstatus==2: - webnotes.throw(_("Account") + ": " + self.doc.account + _(" is not active")) + frappe.throw(_("Account") + ": " + self.doc.account + _(" is not active")) if ret.company != self.doc.company: - webnotes.throw(_("Account") + ": " + self.doc.account + + frappe.throw(_("Account") + ": " + self.doc.account + _(" does not belong to the company") + ": " + self.doc.company) def validate_cost_center(self): @@ -80,27 +80,27 @@ class DocType: def _get_cost_center_company(): if not self.cost_center_company.get(self.doc.cost_center): - self.cost_center_company[self.doc.cost_center] = webnotes.conn.get_value( + self.cost_center_company[self.doc.cost_center] = frappe.conn.get_value( "Cost Center", self.doc.cost_center, "company") return self.cost_center_company[self.doc.cost_center] if self.doc.cost_center and _get_cost_center_company() != self.doc.company: - webnotes.throw(_("Cost Center") + ": " + self.doc.cost_center + + frappe.throw(_("Cost Center") + ": " + self.doc.cost_center + _(" does not belong to the company") + ": " + self.doc.company) def check_negative_balance(account, adv_adj=False): if not adv_adj and account: - account_details = webnotes.conn.get_value("Account", account, + account_details = frappe.conn.get_value("Account", account, ["allow_negative_balance", "debit_or_credit"], as_dict=True) if not account_details["allow_negative_balance"]: - balance = webnotes.conn.sql("""select sum(debit) - sum(credit) from `tabGL Entry` + balance = frappe.conn.sql("""select sum(debit) - sum(credit) from `tabGL Entry` where account = %s""", account) balance = account_details["debit_or_credit"] == "Debit" and \ flt(balance[0][0]) or -1*flt(balance[0][0]) if flt(balance) < 0: - webnotes.throw(_("Negative balance is not allowed for account ") + account) + frappe.throw(_("Negative balance is not allowed for account ") + account) def check_freezing_date(posting_date, adv_adj=False): """ @@ -108,17 +108,17 @@ def check_freezing_date(posting_date, adv_adj=False): except authorized person """ if not adv_adj: - acc_frozen_upto = webnotes.conn.get_value('Accounts Settings', None, 'acc_frozen_upto') + acc_frozen_upto = frappe.conn.get_value('Accounts Settings', None, 'acc_frozen_upto') if acc_frozen_upto: - bde_auth_role = webnotes.conn.get_value( 'Accounts Settings', None,'bde_auth_role') + bde_auth_role = frappe.conn.get_value( 'Accounts Settings', None,'bde_auth_role') if getdate(posting_date) <= getdate(acc_frozen_upto) \ - and not bde_auth_role in webnotes.user.get_roles(): - webnotes.throw(_("You are not authorized to do/modify back dated entries before ") + and not bde_auth_role in frappe.user.get_roles(): + frappe.throw(_("You are not authorized to do/modify back dated entries before ") + getdate(acc_frozen_upto).strftime('%d-%m-%Y')) def update_outstanding_amt(account, against_voucher_type, against_voucher, on_cancel=False): # get final outstanding amt - bal = flt(webnotes.conn.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) + bal = flt(frappe.conn.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` where against_voucher_type=%s and against_voucher=%s and account = %s""", (against_voucher_type, against_voucher, account))[0][0] or 0.0) @@ -126,7 +126,7 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca if against_voucher_type == 'Purchase Invoice': bal = -bal elif against_voucher_type == "Journal Voucher": - against_voucher_amount = flt(webnotes.conn.sql(""" + against_voucher_amount = flt(frappe.conn.sql(""" select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s and account = %s and ifnull(against_voucher, '') = ''""", @@ -137,23 +137,23 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca # Validation : Outstanding can not be negative if bal < 0 and not on_cancel: - webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") + + frappe.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") + fmt_money(bal) + _(". Outstanding cannot be less than zero. \ Please match exact outstanding.")) # Update outstanding amt on against voucher if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]: - webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" % + frappe.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" % (against_voucher_type, bal, against_voucher)) def validate_frozen_account(account, adv_adj=None): - frozen_account = webnotes.conn.get_value("Account", account, "freeze_account") + frozen_account = frappe.conn.get_value("Account", account, "freeze_account") if frozen_account == 'Yes' and not adv_adj: - frozen_accounts_modifier = webnotes.conn.get_value( 'Accounts Settings', None, + frozen_accounts_modifier = frappe.conn.get_value( 'Accounts Settings', None, 'frozen_accounts_modifier') if not frozen_accounts_modifier: - webnotes.throw(account + _(" is a frozen account. Either make the account active or assign role in Accounts Settings who can create / modify entries against this account")) - elif frozen_accounts_modifier not in webnotes.user.get_roles(): - webnotes.throw(account + _(" is a frozen account. To create / edit transactions against this account, you need role") \ + frappe.throw(account + _(" is a frozen account. Either make the account active or assign role in Accounts Settings who can create / modify entries against this account")) + elif frozen_accounts_modifier not in frappe.user.get_roles(): + frappe.throw(account + _(" is a frozen account. To create / edit transactions against this account, you need role") \ + ": " + frozen_accounts_modifier) diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 342fa23afad..1107ba4a6cb 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -1,9 +1,9 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -wn.provide("erpnext.accounts"); +frappe.provide("erpnext.accounts"); -erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ +erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ onload: function() { this.load_defaults(); this.setup_queries(); @@ -11,10 +11,10 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ load_defaults: function() { if(this.frm.doc.__islocal && this.frm.doc.company) { - wn.model.set_default_values(this.frm.doc); - $.each(wn.model.get_doclist(this.frm.doc.doctype, + frappe.model.set_default_values(this.frm.doc); + $.each(frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) { - wn.model.set_default_values(jvd); + frappe.model.set_default_values(jvd); } ); @@ -27,7 +27,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ $.each(["account", "cost_center"], function(i, fieldname) { me.frm.set_query(fieldname, "entries", function() { - wn.model.validate_missing(me.frm.doc, "company"); + frappe.model.validate_missing(me.frm.doc, "company"); return { filters: { company: me.frm.doc.company, @@ -40,8 +40,8 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ $.each([["against_voucher", "Purchase Invoice", "credit_to"], ["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) { me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) { - var jvd = wn.model.get_doc(cdt, cdn); - wn.model.validate_missing(jvd, "account"); + var jvd = frappe.model.get_doc(cdt, cdn); + frappe.model.validate_missing(jvd, "account"); return { filters: [ [opts[1], opts[2], "=", jvd.account], @@ -53,8 +53,8 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ }); this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) { - var jvd = wn.model.get_doc(cdt, cdn); - wn.model.validate_missing(jvd, "account"); + var jvd = frappe.model.get_doc(cdt, cdn); + frappe.model.validate_missing(jvd, "account"); return { query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv", @@ -64,7 +64,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ }, against_voucher: function(doc, cdt, cdn) { - var d = wn.model.get_doc(cdt, cdn); + var d = frappe.model.get_doc(cdt, cdn); if (d.against_voucher && !flt(d.debit)) { this.get_outstanding({ 'doctype': 'Purchase Invoice', @@ -74,7 +74,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ }, against_invoice: function(doc, cdt, cdn) { - var d = wn.model.get_doc(cdt, cdn); + var d = frappe.model.get_doc(cdt, cdn); if (d.against_invoice && !flt(d.credit)) { this.get_outstanding({ 'doctype': 'Sales Invoice', @@ -84,7 +84,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({ }, against_jv: function(doc, cdt, cdn) { - var d = wn.model.get_doc(cdt, cdn); + var d = frappe.model.get_doc(cdt, cdn); if (d.against_jv && !flt(d.credit) && !flt(d.debit)) { this.get_outstanding({ 'doctype': 'Journal Voucher', @@ -115,15 +115,15 @@ cur_frm.cscript.refresh = function(doc) { erpnext.hide_naming_series(); cur_frm.cscript.voucher_type(doc); if(doc.docstatus==1) { - cur_frm.appframe.add_button(wn._('View Ledger'), function() { - wn.route_options = { + cur_frm.appframe.add_button(frappe._('View Ledger'), function() { + frappe.route_options = { "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, "company": doc.company, group_by_voucher: 0 }; - wn.set_route("query-report", "General Ledger"); + frappe.set_route("query-report", "General Ledger"); }, "icon-table"); } } @@ -166,7 +166,7 @@ cur_frm.cscript.get_balance = function(doc,dt,dn) { cur_frm.cscript.account = function(doc,dt,dn) { var d = locals[dt][dn]; if(d.account) { - return wn.call({ + return frappe.call({ method: "erpnext.accounts.utils.get_balance_on", args: {account: d.account, date: doc.posting_date}, callback: function(r) { @@ -187,20 +187,20 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ cur_frm.pformat.print_heading = doc.select_print_heading; } else - cur_frm.pformat.print_heading = wn._("Journal Voucher"); + cur_frm.pformat.print_heading = frappe._("Journal Voucher"); } cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher"); cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher"); - if(wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late + if(frappe.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late || !doc.company) // too early return; var update_jv_details = function(doc, r) { $.each(r.message, function(i, d) { - var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries"); + var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries"); jvdetail.account = d.account; jvdetail.balance = d.balance; }); @@ -208,7 +208,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { } if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) { - return wn.call({ + return frappe.call({ type: "GET", method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account", args: { @@ -222,14 +222,14 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { } }) } else if(doc.voucher_type=="Opening Entry") { - return wn.call({ + return frappe.call({ type:"GET", method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_opening_accounts", args: { "company": doc.company }, callback: function(r) { - wn.model.clear_table("Journal Voucher Detail", "Journal Voucher", + frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher", doc.name, "entries"); if(r.message) { update_jv_details(doc, r); diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index c9ca0c2e376..f02188baef9 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -2,12 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe -from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate -from webnotes.model.doc import addchild -from webnotes.model.bean import getlist -from webnotes import msgprint, _ +from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate +from frappe.model.doc import addchild +from frappe.model.bean import getlist +from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency from erpnext.controllers.accounts_controller import AccountsController @@ -54,7 +54,7 @@ class DocType(AccountsController): def on_trash(self): pass #if self.doc.amended_from: - # webnotes.delete_doc("Journal Voucher", self.doc.amended_from) + # frappe.delete_doc("Journal Voucher", self.doc.amended_from) def validate_debit_credit(self): for d in getlist(self.doclist, 'entries'): @@ -75,7 +75,7 @@ class DocType(AccountsController): for d in getlist(self.doclist,'entries'): if not d.is_advance and not d.against_voucher and \ not d.against_invoice and not d.against_jv: - master_type = webnotes.conn.get_value("Account", d.account, "master_type") + master_type = frappe.conn.get_value("Account", d.account, "master_type") if (master_type == 'Customer' and flt(d.credit) > 0) or \ (master_type == 'Supplier' and flt(d.debit) > 0): msgprint("Message: Please check Is Advance as 'Yes' against \ @@ -87,7 +87,7 @@ class DocType(AccountsController): if d.against_jv == self.doc.name: msgprint("You can not enter current voucher in 'Against JV' column", raise_exception=1) - elif not webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + elif not frappe.conn.sql("""select name from `tabJournal Voucher Detail` where account = '%s' and docstatus = 1 and parent = '%s'""" % (d.account, d.against_jv)): msgprint("Against JV: %s is not valid." % d.against_jv, raise_exception=1) @@ -125,12 +125,12 @@ class DocType(AccountsController): for d in getlist(self.doclist, 'entries'): if d.against_invoice and d.credit: - currency = webnotes.conn.get_value("Sales Invoice", d.against_invoice, "currency") + currency = frappe.conn.get_value("Sales Invoice", d.against_invoice, "currency") r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice)) if d.against_voucher and d.debit: - bill_no = webnotes.conn.sql("""select bill_no, bill_date, currency + bill_no = frappe.conn.sql("""select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s""", d.against_voucher) if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \ not in ['na', 'not applicable', 'none']: @@ -144,7 +144,7 @@ class DocType(AccountsController): if r: self.doc.remark = ("\n").join(r) else: - webnotes.msgprint("User Remarks is mandatory", raise_exception=1) + frappe.msgprint("User Remarks is mandatory", raise_exception=1) def set_aging_date(self): if self.doc.is_opening != 'Yes': @@ -153,7 +153,7 @@ class DocType(AccountsController): # check account type whether supplier or customer exists = False for d in getlist(self.doclist, 'entries'): - account_type = webnotes.conn.get_value("Account", d.account, "account_type") + account_type = frappe.conn.get_value("Account", d.account, "account_type") if account_type in ["Supplier", "Customer"]: exists = True break @@ -166,12 +166,12 @@ class DocType(AccountsController): def set_print_format_fields(self): for d in getlist(self.doclist, 'entries'): - account_type, master_type = webnotes.conn.get_value("Account", d.account, + account_type, master_type = frappe.conn.get_value("Account", d.account, ["account_type", "master_type"]) if master_type in ['Supplier', 'Customer']: if not self.doc.pay_to_recd_from: - self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, + self.doc.pay_to_recd_from = frappe.conn.get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name') @@ -179,7 +179,7 @@ class DocType(AccountsController): company_currency = get_company_currency(self.doc.company) amt = flt(d.debit) and d.debit or d.credit self.doc.total_amount = company_currency + ' ' + cstr(amt) - from webnotes.utils import money_in_words + from frappe.utils import money_in_words self.doc.total_amount_in_words = money_in_words(amt, company_currency) def check_credit_days(self): @@ -190,7 +190,7 @@ class DocType(AccountsController): if date_diff <= 0: return # Get List of Customer Account - acc_list = filter(lambda d: webnotes.conn.get_value("Account", d.account, + acc_list = filter(lambda d: frappe.conn.get_value("Account", d.account, "master_type")=='Customer', getlist(self.doclist,'entries')) for d in acc_list: @@ -202,11 +202,11 @@ class DocType(AccountsController): def get_credit_days_for(self, ac): if not self.credit_days_for.has_key(ac): - self.credit_days_for[ac] = cint(webnotes.conn.get_value("Account", ac, "credit_days")) + self.credit_days_for[ac] = cint(frappe.conn.get_value("Account", ac, "credit_days")) if not self.credit_days_for[ac]: if self.credit_days_global==-1: - self.credit_days_global = cint(webnotes.conn.get_value("Company", + self.credit_days_global = cint(frappe.conn.get_value("Company", self.doc.company, "credit_days")) return self.credit_days_global @@ -218,25 +218,25 @@ class DocType(AccountsController): self.is_approving_authority = 0 # Fetch credit controller role - approving_authority = webnotes.conn.get_value("Global Defaults", None, + approving_authority = frappe.conn.get_value("Global Defaults", None, "credit_controller") # Check logged-in user is authorized - if approving_authority in webnotes.user.get_roles(): + if approving_authority in frappe.user.get_roles(): self.is_approving_authority = 1 return self.is_approving_authority def check_account_against_entries(self): for d in self.doclist.get({"parentfield": "entries"}): - if d.against_invoice and webnotes.conn.get_value("Sales Invoice", + if d.against_invoice and frappe.conn.get_value("Sales Invoice", d.against_invoice, "debit_to") != d.account: - webnotes.throw(_("Row #") + cstr(d.idx) + ": " + + frappe.throw(_("Row #") + cstr(d.idx) + ": " + _("Account is not matching with Debit To account of Sales Invoice")) - if d.against_voucher and webnotes.conn.get_value("Purchase Invoice", + if d.against_voucher and frappe.conn.get_value("Purchase Invoice", d.against_voucher, "credit_to") != d.account: - webnotes.throw(_("Row #") + cstr(d.idx) + ": " + + frappe.throw(_("Row #") + cstr(d.idx) + ": " + _("Account is not matching with Credit To account of Purchase Invoice")) def make_gl_entries(self, cancel=0, adv_adj=0): @@ -267,7 +267,7 @@ class DocType(AccountsController): def check_credit_limit(self): for d in self.doclist.get({"parentfield": "entries"}): - master_type, master_name = webnotes.conn.get_value("Account", d.account, + master_type, master_name = frappe.conn.get_value("Account", d.account, ["master_type", "master_name"]) if master_type == "Customer" and master_name: super(DocType, self).check_credit_limit(d.account) @@ -328,18 +328,18 @@ class DocType(AccountsController): cond = (flt(self.doc.write_off_amount) > 0) and \ ' and outstanding_amount <= '+ self.doc.write_off_amount or '' if self.doc.write_off_based_on == 'Accounts Receivable': - return webnotes.conn.sql("""select name, debit_to, outstanding_amount + return frappe.conn.sql("""select name, debit_to, outstanding_amount from `tabSales Invoice` where docstatus = 1 and company = %s and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company) elif self.doc.write_off_based_on == 'Accounts Payable': - return webnotes.conn.sql("""select name, credit_to, outstanding_amount + return frappe.conn.sql("""select name, credit_to, outstanding_amount from `tabPurchase Invoice` where docstatus = 1 and company = %s and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company) -@webnotes.whitelist() +@frappe.whitelist() def get_default_bank_cash_account(company, voucher_type): from erpnext.accounts.utils import get_balance_on - account = webnotes.conn.get_value("Company", company, + account = frappe.conn.get_value("Company", company, voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account") if account: return { @@ -347,10 +347,10 @@ def get_default_bank_cash_account(company, voucher_type): "balance": get_balance_on(account) } -@webnotes.whitelist() +@frappe.whitelist() def get_payment_entry_from_sales_invoice(sales_invoice): from erpnext.accounts.utils import get_balance_on - si = webnotes.bean("Sales Invoice", sales_invoice) + si = frappe.bean("Sales Invoice", sales_invoice) jv = get_payment_entry(si.doc) jv.doc.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.doc.fields @@ -365,10 +365,10 @@ def get_payment_entry_from_sales_invoice(sales_invoice): return [d.fields for d in jv.doclist] -@webnotes.whitelist() +@frappe.whitelist() def get_payment_entry_from_purchase_invoice(purchase_invoice): from erpnext.accounts.utils import get_balance_on - pi = webnotes.bean("Purchase Invoice", purchase_invoice) + pi = frappe.bean("Purchase Invoice", purchase_invoice) jv = get_payment_entry(pi.doc) jv.doc.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.doc.fields @@ -386,7 +386,7 @@ def get_payment_entry_from_purchase_invoice(purchase_invoice): def get_payment_entry(doc): bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher") - jv = webnotes.new_bean('Journal Voucher') + jv = frappe.new_bean('Journal Voucher') jv.doc.voucher_type = 'Bank Voucher' jv.doc.company = doc.company @@ -408,42 +408,42 @@ def get_payment_entry(doc): return jv -@webnotes.whitelist() +@frappe.whitelist() def get_opening_accounts(company): """get all balance sheet accounts for opening entry""" from erpnext.accounts.utils import get_balance_on - accounts = webnotes.conn.sql_list("""select name from tabAccount + accounts = frappe.conn.sql_list("""select name from tabAccount where group_or_ledger='Ledger' and is_pl_account='No' and company=%s""", company) return [{"account": a, "balance": get_balance_on(a)} for a in accounts] def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters): - return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date + return frappe.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date from `tabPurchase Invoice` where credit_to = %s and docstatus = 1 and outstanding_amount > 0 and %s like %s order by name desc limit %s, %s""" % ("%s", searchfield, "%s", "%s", "%s"), (filters["account"], "%%%s%%" % txt, start, page_len)) def get_against_sales_invoice(doctype, txt, searchfield, start, page_len, filters): - return webnotes.conn.sql("""select name, debit_to, outstanding_amount + return frappe.conn.sql("""select name, debit_to, outstanding_amount from `tabSales Invoice` where debit_to = %s and docstatus = 1 and outstanding_amount > 0 and `%s` like %s order by name desc limit %s, %s""" % ("%s", searchfield, "%s", "%s", "%s"), (filters["account"], "%%%s%%" % txt, start, page_len)) def get_against_jv(doctype, txt, searchfield, start, page_len, filters): - return webnotes.conn.sql("""select jv.name, jv.posting_date, jv.user_remark + return frappe.conn.sql("""select jv.name, jv.posting_date, jv.user_remark from `tabJournal Voucher` jv, `tabJournal Voucher Detail` jv_detail where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1 and jv.%s like %s order by jv.name desc limit %s, %s""" % ("%s", searchfield, "%s", "%s", "%s"), (filters["account"], "%%%s%%" % txt, start, page_len)) -@webnotes.whitelist() +@frappe.whitelist() def get_outstanding(args): args = eval(args) if args.get("doctype") == "Journal Voucher" and args.get("account"): - against_jv_amount = webnotes.conn.sql(""" + against_jv_amount = frappe.conn.sql(""" select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabJournal Voucher Detail` where parent=%s and account=%s and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')='' @@ -457,11 +457,11 @@ def get_outstanding(args): elif args.get("doctype") == "Sales Invoice": return { - "credit": flt(webnotes.conn.get_value("Sales Invoice", args["docname"], + "credit": flt(frappe.conn.get_value("Sales Invoice", args["docname"], "outstanding_amount")) } elif args.get("doctype") == "Purchase Invoice": return { - "debit": flt(webnotes.conn.get_value("Purchase Invoice", args["docname"], + "debit": flt(frappe.conn.get_value("Purchase Invoice", args["docname"], "outstanding_amount")) } diff --git a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py index 587445f2ef4..4497726aeca 100644 --- a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py @@ -4,40 +4,40 @@ from __future__ import unicode_literals import unittest -import webnotes +import frappe class TestJournalVoucher(unittest.TestCase): def test_journal_voucher_with_against_jv(self): self.clear_account_balance() - jv_invoice = webnotes.bean(copy=test_records[2]) + jv_invoice = frappe.bean(copy=test_records[2]) jv_invoice.insert() jv_invoice.submit() - self.assertTrue(not webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_jv=%s""", jv_invoice.doc.name)) - jv_payment = webnotes.bean(copy=test_records[0]) + jv_payment = frappe.bean(copy=test_records[0]) jv_payment.doclist[1].against_jv = jv_invoice.doc.name jv_payment.insert() jv_payment.submit() - self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_jv=%s""", jv_invoice.doc.name)) - self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_jv=%s and credit=400""", jv_invoice.doc.name)) # cancel jv_invoice jv_invoice.cancel() - self.assertTrue(not webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_jv=%s""", jv_invoice.doc.name)) def test_jv_against_stock_account(self): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory set_perpetual_inventory() - jv = webnotes.bean(copy=test_records[0]) + jv = frappe.bean(copy=test_records[0]) jv.doclist[1].account = "_Test Warehouse - _TC" jv.insert() @@ -47,25 +47,25 @@ class TestJournalVoucher(unittest.TestCase): set_perpetual_inventory(0) def test_monthly_budget_crossed_ignore(self): - webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") + frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") self.clear_account_balance() - jv = webnotes.bean(copy=test_records[0]) + jv = frappe.bean(copy=test_records[0]) jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[2].cost_center = "_Test Cost Center - _TC" jv.doclist[2].debit = 20000.0 jv.doclist[1].credit = 20000.0 jv.insert() jv.submit() - self.assertTrue(webnotes.conn.get_value("GL Entry", + self.assertTrue(frappe.conn.get_value("GL Entry", {"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name})) def test_monthly_budget_crossed_stop(self): from erpnext.accounts.utils import BudgetError - webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") + frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") self.clear_account_balance() - jv = webnotes.bean(copy=test_records[0]) + jv = frappe.bean(copy=test_records[0]) jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[2].cost_center = "_Test Cost Center - _TC" jv.doclist[2].debit = 20000.0 @@ -74,16 +74,16 @@ class TestJournalVoucher(unittest.TestCase): self.assertRaises(BudgetError, jv.submit) - webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") + frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") def test_yearly_budget_crossed_stop(self): from erpnext.accounts.utils import BudgetError self.clear_account_balance() self.test_monthly_budget_crossed_ignore() - webnotes.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop") + frappe.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop") - jv = webnotes.bean(copy=test_records[0]) + jv = frappe.bean(copy=test_records[0]) jv.doc.posting_date = "2013-08-12" jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[2].cost_center = "_Test Cost Center - _TC" @@ -93,39 +93,39 @@ class TestJournalVoucher(unittest.TestCase): self.assertRaises(BudgetError, jv.submit) - webnotes.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore") + frappe.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore") def test_monthly_budget_on_cancellation(self): from erpnext.accounts.utils import BudgetError - webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") + frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") self.clear_account_balance() - jv = webnotes.bean(copy=test_records[0]) + jv = frappe.bean(copy=test_records[0]) jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[1].cost_center = "_Test Cost Center - _TC" jv.doclist[1].credit = 30000.0 jv.doclist[2].debit = 30000.0 jv.submit() - self.assertTrue(webnotes.conn.get_value("GL Entry", + self.assertTrue(frappe.conn.get_value("GL Entry", {"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name})) - jv1 = webnotes.bean(copy=test_records[0]) + jv1 = frappe.bean(copy=test_records[0]) jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv1.doclist[2].cost_center = "_Test Cost Center - _TC" jv1.doclist[2].debit = 40000.0 jv1.doclist[1].credit = 40000.0 jv1.submit() - self.assertTrue(webnotes.conn.get_value("GL Entry", + self.assertTrue(frappe.conn.get_value("GL Entry", {"voucher_type": "Journal Voucher", "voucher_no": jv1.doc.name})) self.assertRaises(BudgetError, jv.cancel) - webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") + frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") def clear_account_balance(self): - webnotes.conn.sql("""delete from `tabGL Entry`""") + frappe.conn.sql("""delete from `tabGL Entry`""") test_records = [ diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py index cb6190f2985..26c87f1c04a 100644 --- a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py +++ b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe class DocType: def __init__(self, d, dl): diff --git a/erpnext/accounts/doctype/mis_control/mis_control.py b/erpnext/accounts/doctype/mis_control/mis_control.py index d2c09613a9e..102fb017879 100644 --- a/erpnext/accounts/doctype/mis_control/mis_control.py +++ b/erpnext/accounts/doctype/mis_control/mis_control.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes -from webnotes.utils import flt, get_first_day, get_last_day, has_common -import webnotes.defaults +import frappe +from frappe.utils import flt, get_first_day, get_last_day, has_common +import frappe.defaults from erpnext.accounts.utils import get_balance_on class DocType: @@ -33,7 +33,7 @@ class DocType: ret['company'] = get_companies() #--- to get fiscal year and start_date of that fiscal year ----- - res = webnotes.conn.sql("select name, year_start_date from `tabFiscal Year`") + res = frappe.conn.sql("select name, year_start_date from `tabFiscal Year`") ret['fiscal_year'] = [r[0] for r in res] ret['start_dates'] = {} for r in res: @@ -41,7 +41,7 @@ class DocType: #--- from month and to month (for MIS - Comparison Report) ------- month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] - fiscal_start_month = webnotes.conn.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_default("fiscal_year"))) + fiscal_start_month = frappe.conn.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(frappe.defaults.get_global_default("fiscal_year"))) fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1 mon = [''] for i in range(fiscal_start_month,13): mon.append(month_list[i-1]) @@ -49,7 +49,7 @@ class DocType: ret['month'] = mon # get MIS Type on basis of roles of session user - self.roles = webnotes.user.get_roles() + self.roles = frappe.user.get_roles() if has_common(self.roles, ['Sales Manager']): type.append('Sales') if has_common(self.roles, ['Purchase Manager']): @@ -76,7 +76,7 @@ class DocType: return self.return_data def get_children(self, parent_account, level, pl, company, fy): - cl = webnotes.conn.sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company)) + cl = frappe.conn.sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company)) level0_diff = [0 for p in self.period_list] if pl=='Yes' and level==0: # switch for income & expenses cl = [c for c in cl] @@ -123,7 +123,7 @@ class DocType: self.return_data.append([4, 'Total '+c[0]] + totals) def define_periods(self, year, period): - ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year) + ysd = frappe.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year) ysd = ysd and ysd[0][0] or '' self.ysd = ysd diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py index cb6190f2985..26c87f1c04a 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe class DocType: def __init__(self, d, dl): diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js index 6f7d5154498..48cb789bd88 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js @@ -13,15 +13,15 @@ cur_frm.cscript.onload_post_render = function(doc) { cur_frm.cscript.refresh = function(doc) { cur_frm.set_intro(""); if(!doc.voucher_no) { - cur_frm.set_intro(wn._("Select the Invoice against which you want to allocate payments.")); + cur_frm.set_intro(frappe._("Select the Invoice against which you want to allocate payments.")); } else { - cur_frm.set_intro(wn._("Set allocated amount against each Payment Entry and click 'Allocate'.")); + cur_frm.set_intro(frappe._("Set allocated amount against each Payment Entry and click 'Allocate'.")); } } cur_frm.fields_dict.voucher_no.get_query = function(doc) { // TO-do: check for pos, it should not come - if (!doc.account) msgprint(wn._("Please select Account first")); + if (!doc.account) msgprint(frappe._("Please select Account first")); else { return { doctype: doc.voucher_type, @@ -40,7 +40,7 @@ cur_frm.cscript.voucher_no =function(doc, cdt, cdn) { } cur_frm.cscript.account = function(doc, cdt, cdn) { - return wn.call({ + return frappe.call({ doc: this.frm.doc, method: "set_account_type", callback: function(r) { diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py index 2904c7d6952..ceea672a57c 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py @@ -2,12 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe -from webnotes.utils import flt -from webnotes.model.doc import addchild -from webnotes.model.bean import getlist -from webnotes import msgprint +from frappe.utils import flt +from frappe.model.doc import addchild +from frappe.model.bean import getlist +from frappe import msgprint class DocType: def __init__(self, doc, doclist): @@ -16,17 +16,17 @@ class DocType: def set_account_type(self): self.doc.account_type = self.doc.account and \ - webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or "" + frappe.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or "" def get_voucher_details(self): - total_amount = webnotes.conn.sql("""select sum(%s) from `tabGL Entry` + total_amount = frappe.conn.sql("""select sum(%s) from `tabGL Entry` where voucher_type = %s and voucher_no = %s and account = %s""" % (self.doc.account_type, '%s', '%s', '%s'), (self.doc.voucher_type, self.doc.voucher_no, self.doc.account)) total_amount = total_amount and flt(total_amount[0][0]) or 0 - reconciled_payment = webnotes.conn.sql(""" + reconciled_payment = frappe.conn.sql(""" select sum(ifnull(%s, 0)) - sum(ifnull(%s, 0)) from `tabGL Entry` where against_voucher = %s and voucher_no != %s and account = %s""" % @@ -63,7 +63,7 @@ class DocType: cond += self.doc.amt_less_than and \ ' and t2.' + dc+' <= ' + self.doc.amt_less_than or '' - gle = webnotes.conn.sql(""" + gle = frappe.conn.sql(""" select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt, sum(ifnull(t2.credit, 0)) - sum(ifnull(t2.debit, 0)) as amt_due, t1.remark, t2.against_account, t2.name as voucher_detail_no @@ -99,7 +99,7 @@ class DocType: 2. split into multiple rows if partially adjusted, assign against voucher 3. submit payment voucher """ - if not self.doc.voucher_no or not webnotes.conn.sql("""select name from `tab%s` + if not self.doc.voucher_no or not frappe.conn.sql("""select name from `tab%s` where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no): msgprint("Please select valid Voucher No to proceed", raise_exception=1) @@ -130,7 +130,7 @@ class DocType: def gl_entry_details(doctype, txt, searchfield, start, page_len, filters): from erpnext.controllers.queries import get_match_cond - return webnotes.conn.sql("""select gle.voucher_no, gle.posting_date, + return frappe.conn.sql("""select gle.voucher_no, gle.posting_date, gle.%(account_type)s from `tabGL Entry` gle where gle.account = '%(acc)s' and gle.voucher_type = '%(dt)s' diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py index 7cf8c06db4b..fed02523765 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py @@ -3,6 +3,6 @@ from __future__ import unicode_literals import unittest -import webnotes +import frappe test_records = [] \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py index cb6190f2985..26c87f1c04a 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe class DocType: def __init__(self, d, dl): diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 5a37d84cdce..753b7dbe078 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes -from webnotes.utils import cstr, flt, getdate -from webnotes import msgprint, _ +import frappe +from frappe.utils import cstr, flt, getdate +from frappe import msgprint, _ from erpnext.controllers.accounts_controller import AccountsController class DocType(AccountsController): @@ -21,30 +21,30 @@ class DocType(AccountsController): self.make_gl_entries() def on_cancel(self): - webnotes.conn.sql("""delete from `tabGL Entry` + frappe.conn.sql("""delete from `tabGL Entry` where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name) def validate_account_head(self): - debit_or_credit, is_pl_account = webnotes.conn.get_value("Account", + debit_or_credit, is_pl_account = frappe.conn.get_value("Account", self.doc.closing_account_head, ["debit_or_credit", "is_pl_account"]) if debit_or_credit != 'Credit' or is_pl_account != 'No': - webnotes.throw(_("Account") + ": " + self.doc.closing_account_head + + frappe.throw(_("Account") + ": " + self.doc.closing_account_head + _("must be a Liability account")) def validate_posting_date(self): from erpnext.accounts.utils import get_fiscal_year self.year_start_date = get_fiscal_year(self.doc.posting_date, self.doc.fiscal_year)[1] - pce = webnotes.conn.sql("""select name from `tabPeriod Closing Voucher` + pce = frappe.conn.sql("""select name from `tabPeriod Closing Voucher` where posting_date > %s and fiscal_year = %s and docstatus = 1""", (self.doc.posting_date, self.doc.fiscal_year)) if pce and pce[0][0]: - webnotes.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) + + frappe.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) + _("has been made after posting date") + ": " + self.doc.posting_date) def validate_pl_balances(self): - income_bal = webnotes.conn.sql(""" + income_bal = frappe.conn.sql(""" select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, tabAccount t2 where t1.account = t2.name and t1.posting_date between %s and %s @@ -52,7 +52,7 @@ class DocType(AccountsController): and t2.docstatus < 2 and t2.company = %s""", (self.year_start_date, self.doc.posting_date, self.doc.company)) - expense_bal = webnotes.conn.sql(""" + expense_bal = frappe.conn.sql(""" select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, tabAccount t2 where t1.account = t2.name and t1.posting_date between %s and %s @@ -64,11 +64,11 @@ class DocType(AccountsController): expense_bal = expense_bal and expense_bal[0][0] or 0 if not income_bal and not expense_bal: - webnotes.throw(_("Both Income and Expense balances are zero. No Need to make Period Closing Entry.")) + frappe.throw(_("Both Income and Expense balances are zero. No Need to make Period Closing Entry.")) def get_pl_balances(self): """Get balance for pl accounts""" - return webnotes.conn.sql(""" + return frappe.conn.sql(""" select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) as balance from `tabGL Entry` t1, `tabAccount` t2 where t1.account = t2.name and ifnull(t2.is_pl_account, 'No') = 'Yes' diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py index c779d9be86d..5039e884892 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py @@ -4,30 +4,30 @@ from __future__ import unicode_literals import unittest -import webnotes +import frappe class TestPeriodClosingVoucher(unittest.TestCase): def test_closing_entry(self): # clear GL Entries - webnotes.conn.sql("""delete from `tabGL Entry`""") + frappe.conn.sql("""delete from `tabGL Entry`""") from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records - jv = webnotes.bean(copy=jv_records[2]) + jv = frappe.bean(copy=jv_records[2]) jv.insert() jv.submit() - jv1 = webnotes.bean(copy=jv_records[0]) + jv1 = frappe.bean(copy=jv_records[0]) jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv1.doclist[2].debit = 600.0 jv1.doclist[1].credit = 600.0 jv1.insert() jv1.submit() - pcv = webnotes.bean(copy=test_record) + pcv = frappe.bean(copy=test_record) pcv.insert() pcv.submit() - gl_entries = webnotes.conn.sql("""select account, debit, credit + gl_entries = frappe.conn.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Period Closing Voucher' and voucher_no=%s order by account asc, debit asc""", pcv.doc.name, as_dict=1) diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index 5c291b403a4..f7fcdfe162d 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -74,5 +74,5 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) { - return{ query:"webnotes.core.doctype.profile.profile.profile_query"} + return{ query:"frappe.core.doctype.profile.profile.profile_query"} } diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py index 31988599454..e743fb34c43 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py @@ -2,17 +2,17 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes -from webnotes import msgprint, _ -from webnotes.utils import cint +import frappe +from frappe import msgprint, _ +from frappe.utils import cint class DocType: def __init__(self,doc,doclist): self.doc, self.doclist = doc,doclist def get_series(self): - import webnotes.model.doctype - docfield = webnotes.model.doctype.get('Sales Invoice') + import frappe.model.doctype + docfield = frappe.model.doctype.get('Sales Invoice') series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series'] return series and series[0] or '' @@ -23,7 +23,7 @@ class DocType: self.validate_all_link_fields() def check_for_duplicate(self): - res = webnotes.conn.sql("""select name, user from `tabPOS Setting` + res = frappe.conn.sql("""select name, user from `tabPOS Setting` where ifnull(user, '') = %s and name != %s and company = %s""", (self.doc.user, self.doc.name, self.doc.company)) if res: @@ -35,7 +35,7 @@ class DocType: (res[0][0], self.doc.company), raise_exception=1) def validate_expense_account(self): - if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \ + if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \ and not self.doc.expense_account: msgprint(_("Expense Account is mandatory"), raise_exception=1) @@ -46,19 +46,19 @@ class DocType: for link_dt, dn_list in accounts.items(): for link_dn in dn_list: - if link_dn and not webnotes.conn.exists({"doctype": link_dt, + if link_dn and not frappe.conn.exists({"doctype": link_dt, "company": self.doc.company, "name": link_dn}): - webnotes.throw(link_dn +_(" does not belong to ") + self.doc.company) + frappe.throw(link_dn +_(" does not belong to ") + self.doc.company) def on_update(self): - webnotes.defaults.clear_default("is_pos") + frappe.defaults.clear_default("is_pos") - pos_view_users = webnotes.conn.sql_list("""select user from `tabPOS Setting`""") + pos_view_users = frappe.conn.sql_list("""select user from `tabPOS Setting`""") for user in pos_view_users: if user: - webnotes.defaults.set_user_default("is_pos", 1, user) + frappe.defaults.set_user_default("is_pos", 1, user) else: - webnotes.defaults.set_global_default("is_pos", 1) + frappe.defaults.set_global_default("is_pos", 1) def on_trash(self): self.on_update() \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index deece757e6a..202179d4d6d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -5,7 +5,7 @@ cur_frm.cscript.tname = "Purchase Invoice Item"; cur_frm.cscript.fname = "entries"; cur_frm.cscript.other_fname = "other_charges"; -wn.provide("erpnext.accounts"); +frappe.provide("erpnext.accounts"); {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} @@ -27,25 +27,25 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ // Show / Hide button if(doc.docstatus==1 && doc.outstanding_amount > 0) - this.frm.add_custom_button(wn._('Make Payment Entry'), this.make_bank_voucher); + this.frm.add_custom_button(frappe._('Make Payment Entry'), this.make_bank_voucher); if(doc.docstatus==1) { - cur_frm.appframe.add_button(wn._('View Ledger'), function() { - wn.route_options = { + cur_frm.appframe.add_button(frappe._('View Ledger'), function() { + frappe.route_options = { "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, "company": doc.company, group_by_voucher: 0 }; - wn.set_route("query-report", "General Ledger"); + frappe.set_route("query-report", "General Ledger"); }, "icon-table"); } if(doc.docstatus===0) { - cur_frm.add_custom_button(wn._('From Purchase Order'), + cur_frm.add_custom_button(frappe._('From Purchase Order'), function() { - wn.model.map_current_doc({ + frappe.model.map_current_doc({ method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice", source_doctype: "Purchase Order", get_query_filters: { @@ -58,9 +58,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }) }); - cur_frm.add_custom_button(wn._('From Purchase Receipt'), + cur_frm.add_custom_button(frappe._('From Purchase Receipt'), function() { - wn.model.map_current_doc({ + frappe.model.map_current_doc({ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", source_doctype: "Purchase Receipt", get_query_filters: { @@ -108,7 +108,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }, entries_add: function(doc, cdt, cdn) { - var row = wn.model.get_doc(cdt, cdn); + var row = frappe.model.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("entries", row, ["expense_account", "cost_center"]); } }); @@ -121,14 +121,14 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) { } cur_frm.cscript.make_bank_voucher = function() { - return wn.call({ + return frappe.call({ method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_payment_entry_from_purchase_invoice", args: { "purchase_invoice": cur_frm.doc.name, }, callback: function(r) { - var doclist = wn.model.sync(r.message); - wn.set_route("Form", doclist[0].doctype, doclist[0].name); + var doclist = frappe.model.sync(r.message); + frappe.set_route("Form", doclist[0].doctype, doclist[0].name); } }); } @@ -229,5 +229,5 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ cur_frm.pformat.print_heading = doc.select_print_heading; } else - cur_frm.pformat.print_heading = wn._("Purchase Invoice"); + cur_frm.pformat.print_heading = frappe._("Purchase Invoice"); } \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index ab7b5b10942..450fdc360c5 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -2,15 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe -from webnotes.utils import add_days, cint, cstr, flt, formatdate -from webnotes.model.bean import getlist -from webnotes.model.code import get_obj -from webnotes import msgprint, _ +from frappe.utils import add_days, cint, cstr, flt, formatdate +from frappe.model.bean import getlist +from frappe.model.code import get_obj +from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency -import webnotes.defaults +import frappe.defaults from erpnext.controllers.buying_controller import BuyingController from erpnext.accounts.party import get_party_account, get_due_date @@ -73,7 +73,7 @@ class DocType(BuyingController): def check_active_purchase_items(self): for d in getlist(self.doclist, 'entries'): if d.item_code: # extra condn coz item_code is not mandatory in PV - valid_item = webnotes.conn.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code) + valid_item = frappe.conn.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code) if valid_item[0][0] == 2: msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code)) raise Exception @@ -93,7 +93,7 @@ class DocType(BuyingController): def validate_bill_no(self): if self.doc.bill_no and self.doc.bill_no.lower().strip() \ not in ['na', 'not applicable', 'none']: - b_no = webnotes.conn.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` + b_no = frappe.conn.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""", (self.doc.bill_no, self.doc.credit_to, self.doc.name)) if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening): @@ -109,7 +109,7 @@ class DocType(BuyingController): self.doc.remarks = "No Remarks" def validate_credit_acc(self): - acc = webnotes.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s", + acc = frappe.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s", self.doc.credit_to) if not acc: msgprint("Account: "+ self.doc.credit_to + "does not exist") @@ -125,7 +125,7 @@ class DocType(BuyingController): # ------------------------------------------------------------ def check_for_acc_head_of_supplier(self): if self.doc.supplier and self.doc.credit_to: - acc_head = webnotes.conn.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to) + acc_head = frappe.conn.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to) if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.supplier)) or (not acc_head and (self.doc.credit_to != cstr(self.doc.supplier) + " - " + self.company_abbr)): msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.doc.credit_to,self.doc.supplier,self.doc.company), raise_exception=1) @@ -137,7 +137,7 @@ class DocType(BuyingController): for d in getlist(self.doclist,'entries'): if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt: check_list.append(d.purhcase_order) - stopped = webnotes.conn.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order) + stopped = frappe.conn.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order) if stopped: msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order)) raise Exception @@ -165,7 +165,7 @@ class DocType(BuyingController): } }) - if cint(webnotes.defaults.get_global_default('maintain_same_rate')): + if cint(frappe.defaults.get_global_default('maintain_same_rate')): super(DocType, self).validate_with_previous_doc(self.tname, { "Purchase Order Item": { "ref_dn_field": "po_detail", @@ -189,7 +189,7 @@ class DocType(BuyingController): raise Exception def set_against_expense_account(self): - auto_accounting_for_stock = cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) + auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) if auto_accounting_for_stock: stock_not_billed_account = self.get_company_default("stock_received_but_not_billed") @@ -218,14 +218,14 @@ class DocType(BuyingController): self.doc.against_expense_account = ",".join(against_accounts) def po_required(self): - if webnotes.conn.get_value("Buying Settings", None, "po_required") == 'Yes': + if frappe.conn.get_value("Buying Settings", None, "po_required") == 'Yes': for d in getlist(self.doclist,'entries'): if not d.purchase_order: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception def pr_required(self): - if webnotes.conn.get_value("Buying Settings", None, "pr_required") == 'Yes': + if frappe.conn.get_value("Buying Settings", None, "pr_required") == 'Yes': for d in getlist(self.doclist,'entries'): if not d.purchase_receipt: msgprint("Purchase Receipt No. required against item %s"%d.item_code) @@ -238,13 +238,13 @@ class DocType(BuyingController): def check_prev_docstatus(self): for d in getlist(self.doclist,'entries'): if d.purchase_order: - submitted = webnotes.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order) + submitted = frappe.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order) if not submitted: - webnotes.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted") + frappe.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted") if d.purchase_receipt: - submitted = webnotes.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt) + submitted = frappe.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt) if not submitted: - webnotes.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted") + frappe.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted") def update_against_document_in_jv(self): @@ -289,7 +289,7 @@ class DocType(BuyingController): def make_gl_entries(self): auto_accounting_for_stock = \ - cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) + cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) gl_entries = [] @@ -324,7 +324,7 @@ class DocType(BuyingController): # accumulate valuation tax if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount): if auto_accounting_for_stock and not tax.cost_center: - webnotes.throw(_("Row %(row)s: Cost Center is mandatory \ + frappe.throw(_("Row %(row)s: Cost Center is mandatory \ if tax/charges category is Valuation or Valuation and Total" % {"row": tax.idx})) valuation_tax.setdefault(tax.cost_center, 0) @@ -414,25 +414,25 @@ class DocType(BuyingController): def update_raw_material_cost(self): if self.sub_contracted_items: for d in self.doclist.get({"parentfield": "entries"}): - rm_cost = webnotes.conn.sql("""select raw_material_cost / quantity + rm_cost = frappe.conn.sql("""select raw_material_cost / quantity from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 and is_active = 1 """, (d.item_code,)) rm_cost = rm_cost and flt(rm_cost[0][0]) or 0 - d.conversion_factor = d.conversion_factor or flt(webnotes.conn.get_value( + d.conversion_factor = d.conversion_factor or flt(frappe.conn.get_value( "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, "conversion_factor")) or 1 d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor) -@webnotes.whitelist() +@frappe.whitelist() def get_expense_account(doctype, txt, searchfield, start, page_len, filters): from erpnext.controllers.queries import get_match_cond # expense account can be any Debit account, # but can also be a Liability account with account_type='Expense Account' in special circumstances. # Hence the first condition is an "OR" - return webnotes.conn.sql("""select tabAccount.name from `tabAccount` + return frappe.conn.sql("""select tabAccount.name from `tabAccount` where (tabAccount.debit_or_credit="Debit" or tabAccount.account_type = "Expense Account") and tabAccount.group_or_ledger="Ledger" diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js index 96bcbb47a73..61d2750c3e1 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt // render -wn.listview_settings['Purchase Invoice'] = { +frappe.listview_settings['Purchase Invoice'] = { add_fields: ["`tabPurchase Invoice`.grand_total", "`tabPurchase Invoice`.outstanding_amount"], add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph", label: "Paid"}], prepare_data: function(data) { diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 6cca6e47d9e..0398e4b3e60 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -4,11 +4,11 @@ from __future__ import unicode_literals import unittest -import webnotes -import webnotes.model +import frappe +import frappe.model import json -from webnotes.utils import cint -import webnotes.defaults +from frappe.utils import cint +import frappe.defaults from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory test_dependencies = ["Item", "Cost Center"] @@ -17,9 +17,9 @@ test_ignore = ["Serial No"] class TestPurchaseInvoice(unittest.TestCase): def test_gl_entries_without_auto_accounting_for_stock(self): set_perpetual_inventory(0) - self.assertTrue(not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock"))) + self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))) - wrapper = webnotes.bean(copy=test_records[0]) + wrapper = frappe.bean(copy=test_records[0]) wrapper.run_method("calculate_taxes_and_totals") wrapper.insert() wrapper.submit() @@ -37,21 +37,21 @@ class TestPurchaseInvoice(unittest.TestCase): "_Test Account VAT - _TC": [156.25, 0], "_Test Account Discount - _TC": [0, 168.03], } - gl_entries = webnotes.conn.sql("""select account, debit, credit from `tabGL Entry` + gl_entries = frappe.conn.sql("""select account, debit, credit from `tabGL Entry` where voucher_type = 'Purchase Invoice' and voucher_no = %s""", dl[0].name, as_dict=1) for d in gl_entries: self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account)) def test_gl_entries_with_auto_accounting_for_stock(self): set_perpetual_inventory(1) - self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1) + self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - pi = webnotes.bean(copy=test_records[1]) + pi = frappe.bean(copy=test_records[1]) pi.run_method("calculate_taxes_and_totals") pi.insert() pi.submit() - gl_entries = webnotes.conn.sql("""select account, debit, credit + gl_entries = frappe.conn.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s order by account asc""", pi.doc.name, as_dict=1) self.assertTrue(gl_entries) @@ -73,9 +73,9 @@ class TestPurchaseInvoice(unittest.TestCase): def test_gl_entries_with_aia_for_non_stock_items(self): set_perpetual_inventory() - self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1) + self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - pi = webnotes.bean(copy=test_records[1]) + pi = frappe.bean(copy=test_records[1]) pi.doclist[1].item_code = "_Test Non Stock Item" pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC" pi.doclist.pop(2) @@ -84,7 +84,7 @@ class TestPurchaseInvoice(unittest.TestCase): pi.insert() pi.submit() - gl_entries = webnotes.conn.sql("""select account, debit, credit + gl_entries = frappe.conn.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s order by account asc""", pi.doc.name, as_dict=1) self.assertTrue(gl_entries) @@ -102,7 +102,7 @@ class TestPurchaseInvoice(unittest.TestCase): set_perpetual_inventory(0) def test_purchase_invoice_calculation(self): - wrapper = webnotes.bean(copy=test_records[0]) + wrapper = frappe.bean(copy=test_records[0]) wrapper.run_method("calculate_taxes_and_totals") wrapper.insert() wrapper.load_from_db() @@ -136,7 +136,7 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEqual(tax.total, expected_values[i][2]) def test_purchase_invoice_with_subcontracted_item(self): - wrapper = webnotes.bean(copy=test_records[0]) + wrapper = frappe.bean(copy=test_records[0]) wrapper.doclist[1].item_code = "_Test FG Item" wrapper.run_method("calculate_taxes_and_totals") wrapper.insert() @@ -174,11 +174,11 @@ class TestPurchaseInvoice(unittest.TestCase): from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ import test_records as jv_test_records - jv = webnotes.bean(copy=jv_test_records[1]) + jv = frappe.bean(copy=jv_test_records[1]) jv.insert() jv.submit() - pi = webnotes.bean(copy=test_records[0]) + pi = frappe.bean(copy=test_records[0]) pi.doclist.append({ "doctype": "Purchase Invoice Advance", "parentfield": "advance_allocation_details", @@ -193,17 +193,17 @@ class TestPurchaseInvoice(unittest.TestCase): pi.submit() pi.load_from_db() - self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_voucher=%s""", pi.doc.name)) - self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_voucher=%s and debit=300""", pi.doc.name)) self.assertEqual(pi.doc.outstanding_amount, 1212.30) pi.cancel() - self.assertTrue(not webnotes.conn.sql("""select name from `tabJournal Voucher Detail` + self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail` where against_voucher=%s""", pi.doc.name)) test_records = [ diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py index cb6190f2985..26c87f1c04a 100644 --- a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py +++ b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe class DocType: def __init__(self, d, dl): diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py index cb6190f2985..26c87f1c04a 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe class DocType: def __init__(self, d, dl): diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py index cb6190f2985..26c87f1c04a 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe class DocType: def __init__(self, d, dl): diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index 933382e5cd9..b87915ac9db 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -4,7 +4,7 @@ {% include "public/js/controllers/accounts.js" %} cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.set_footnote(wn.markdown(cur_frm.meta.description)); + cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description)); } // For customizing print @@ -37,7 +37,7 @@ cur_frm.pformat.other_charges= function(doc) { } function print_hide(fieldname) { - var doc_field = wn.meta.get_docfield(doc.doctype, fieldname, doc.name); + var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name); return doc_field.print_hide; } @@ -78,11 +78,11 @@ cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.category && d.add_deduct_tax) { - msgprint(wn._("Please select Category first")); + msgprint(frappe._("Please select Category first")); d.add_deduct_tax = ''; } else if(d.category != 'Total' && d.add_deduct_tax == 'Deduct') { - msgprint(wn._("You cannot deduct when category is for 'Valuation' or 'Valuation and Total'")); + msgprint(frappe._("You cannot deduct when category is for 'Valuation' or 'Valuation and Total'")); d.add_deduct_tax = ''; } } @@ -91,15 +91,15 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.category && d.charge_type) { - msgprint(wn._("Please select Category first")); + msgprint(frappe._("Please select Category first")); d.charge_type = ''; } else if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) { - msgprint(wn._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")); + msgprint(frappe._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")); d.charge_type = ''; } else if((d.category == 'Valuation' || d.category == 'Valuation and Total') && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) { - msgprint(wn._("You cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total")); + msgprint(frappe._("You cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total")); d.charge_type = ''; } @@ -116,16 +116,16 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.charge_type && d.row_id) { - msgprint(wn._("Please select Charge Type first")); + msgprint(frappe._("Please select Charge Type first")); d.row_id = ''; } else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { - msgprint(wn._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'")); + msgprint(frappe._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'")); d.row_id = ''; } else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) { if(d.row_id >= d.idx){ - msgprint(wn._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type")); + msgprint(frappe._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type")); d.row_id = ''; } } @@ -157,7 +157,7 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.charge_type && d.rate) { - msgprint(wn._("Please select Charge Type first")); + msgprint(frappe._("Please select Charge Type first")); d.rate = ''; } validated = false; @@ -168,11 +168,11 @@ cur_frm.cscript.tax_amount = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.charge_type && d.tax_amount) { - msgprint(wn._("Please select Charge Type first")); + msgprint(frappe._("Please select Charge Type first")); d.tax_amount = ''; } else if(d.charge_type && d.tax_amount) { - msgprint(wn._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate")); + msgprint(frappe._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate")); d.tax_amount = ''; } diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py index 09eb4d81493..eee6e9ac8c3 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py @@ -2,11 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import frappe -from webnotes.model import db_exists -from webnotes.model.bean import copy_doclist -from webnotes.model.code import get_obj +from frappe.model import db_exists +from frappe.model.bean import copy_doclist +from frappe.model.code import get_obj diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js index 673b35b7893..480ce02626a 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.js +++ b/erpnext/accounts/doctype/sales_invoice/pos.js @@ -105,7 +105,7 @@ erpnext.POS = Class.extend({ }); this.wrapper.find('input.discount-amount').on("change", function() { - wn.model.set_value(me.frm.doctype, me.frm.docname, "discount_amount", this.value); + frappe.model.set_value(me.frm.doctype, me.frm.docname, "discount_amount", this.value); }); this.call_function("remove-items", function() {me.remove_selected_items();}); @@ -115,10 +115,10 @@ erpnext.POS = Class.extend({ var me = this; // Check whether the transaction is "Sales" or "Purchase" - if (wn.meta.has_field(cur_frm.doc.doctype, "customer")) { + if (frappe.meta.has_field(cur_frm.doc.doctype, "customer")) { this.set_transaction_defaults("Customer", "export"); } - else if (wn.meta.has_field(cur_frm.doc.doctype, "supplier")) { + else if (frappe.meta.has_field(cur_frm.doc.doctype, "supplier")) { this.set_transaction_defaults("Supplier", "import"); } }, @@ -146,7 +146,7 @@ erpnext.POS = Class.extend({ }, make_party: function() { var me = this; - this.party_field = wn.ui.form.make_control({ + this.party_field = frappe.ui.form.make_control({ df: { "fieldtype": "Link", "options": this.party, @@ -160,13 +160,13 @@ erpnext.POS = Class.extend({ this.party_field.make_input(); this.party_field.$input.on("change", function() { if(!me.party_field.autocomplete_open) - wn.model.set_value(me.frm.doctype, me.frm.docname, + frappe.model.set_value(me.frm.doctype, me.frm.docname, me.party.toLowerCase(), this.value); }); }, make_barcode: function() { var me = this; - this.barcode = wn.ui.form.make_control({ + this.barcode = frappe.ui.form.make_control({ df: { "fieldtype": "Data", "label": "Barcode", @@ -185,7 +185,7 @@ erpnext.POS = Class.extend({ }, make_search: function() { var me = this; - this.search = wn.ui.form.make_control({ + this.search = frappe.ui.form.make_control({ df: { "fieldtype": "Data", "label": "Item", @@ -205,7 +205,7 @@ erpnext.POS = Class.extend({ }, make_item_group: function() { var me = this; - this.item_group = wn.ui.form.make_control({ + this.item_group = frappe.ui.form.make_control({ df: { "fieldtype": "Link", "options": "Item Group", @@ -225,7 +225,7 @@ erpnext.POS = Class.extend({ make_item_list: function() { var me = this; me.item_timeout = null; - wn.call({ + frappe.call({ method: 'erpnext.accounts.doctype.sales_invoice.pos.get_items', args: { sales_or_purchase: this.sales_or_purchase, @@ -284,14 +284,14 @@ erpnext.POS = Class.extend({ // check whether the item is already added if (no_of_items != 0) { - $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, + $.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, this.frm.cscript.fname, this.frm.doctype), function(i, d) { if (d.item_code == item_code) { caught = true; if (serial_no) - wn.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no); + frappe.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no); else - wn.model.set_value(d.doctype, d.name, "qty", d.qty + 1); + frappe.model.set_value(d.doctype, d.name, "qty", d.qty + 1); } }); } @@ -306,7 +306,7 @@ erpnext.POS = Class.extend({ add_new_item_to_grid: function(item_code, serial_no) { var me = this; - var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item", + var child = frappe.model.add_child(me.frm.doc, this.frm.doctype + " Item", this.frm.cscript.fname); child.item_code = item_code; @@ -326,14 +326,14 @@ erpnext.POS = Class.extend({ }, update_qty: function(item_code, qty) { var me = this; - $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, + $.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, this.frm.cscript.fname, this.frm.doctype), function(i, d) { if (d.item_code == item_code) { if (qty == 0) { - wn.model.clear_doc(d.doctype, d.name); + frappe.model.clear_doc(d.doctype, d.name); me.refresh_grid(); } else { - wn.model.set_value(d.doctype, d.name, "qty", qty); + frappe.model.set_value(d.doctype, d.name, "qty", qty); } } }); @@ -378,7 +378,7 @@ erpnext.POS = Class.extend({ var me = this; var $items = this.wrapper.find("#cart tbody").empty(); - $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, + $.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, this.frm.cscript.fname, this.frm.doctype), function(i, d) { $(repl(''+wn._('Please setup your chart of accounts before you start Accounting Entries')+'
'+frappe._('Please setup your chart of accounts before you start Accounting Entries')+'
').appendTo(main); - if (wn.boot.profile.can_create.indexOf("Company") !== -1) { - wrapper.appframe.add_button(wn._('New Company'), function() { newdoc('Company'); }, + if (frappe.boot.profile.can_create.indexOf("Company") !== -1) { + wrapper.appframe.add_button(frappe._('New Company'), function() { newdoc('Company'); }, 'icon-plus'); } @@ -54,21 +54,21 @@ pscript['onload_Accounts Browser'] = function(wrapper){ // company-select wrapper.$company_select = wrapper.appframe.add_select("Company", []) .change(function() { - var ctype = wn.get_route()[1] || 'Account'; + var ctype = frappe.get_route()[1] || 'Account'; erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(), chart_area.get(0)); pscript.set_title(wrapper, ctype, $(this).val()); }) // load up companies - return wn.call({ + return frappe.call({ method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_companies', callback: function(r) { wrapper.$company_select.empty(); $.each(r.message, function(i, v) { $('