-webnotes +frappe :boom:
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 2bc3852..ecc8cf7 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -2,10 +2,10 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
-from webnotes import _, throw
-from webnotes.utils import flt, cint, today, cstr
-from webnotes.model.code import get_obj
+import frappe
+from frappe import _, throw
+from frappe.utils import flt, cint, today, cstr
+from frappe.model.code import get_obj
from erpnext.setup.utils import get_company_currency
from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year
from erpnext.utilities.transaction_base import TransactionBase
@@ -44,7 +44,7 @@
def validate_for_freezed_account(self):
for fieldname in ["customer", "supplier"]:
if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
- accounts = webnotes.conn.get_values("Account",
+ accounts = frappe.conn.get_values("Account",
{"master_type": fieldname.title(), "master_name": self.doc.fields[fieldname],
"company": self.doc.company}, "name")
if accounts:
@@ -60,7 +60,7 @@
fieldname = "selling_price_list" if buying_or_selling.lower() == "selling" \
else "buying_price_list"
if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
- self.doc.price_list_currency = webnotes.conn.get_value("Price List",
+ self.doc.price_list_currency = frappe.conn.get_value("Price List",
self.doc.fields.get(fieldname), "currency")
if self.doc.price_list_currency == company_currency:
@@ -82,7 +82,7 @@
def get_exchange_rate(self, from_currency, to_currency):
exchange = "%s-%s" % (from_currency, to_currency)
- return flt(webnotes.conn.get_value("Currency Exchange", exchange, "exchange_rate"))
+ return flt(frappe.conn.get_value("Currency Exchange", exchange, "exchange_rate"))
def set_missing_item_details(self):
"""set missing item values"""
@@ -106,7 +106,7 @@
if not self.doc.fields.get(tax_master_field):
# get the default tax master
self.doc.fields[tax_master_field] = \
- webnotes.conn.get_value(tax_master_doctype, {"is_default": 1})
+ frappe.conn.get_value(tax_master_doctype, {"is_default": 1})
self.append_taxes_from_master(tax_parentfield, tax_master_field, tax_master_doctype)
@@ -117,8 +117,8 @@
tax_doctype = self.meta.get_field(tax_parentfield).options
- from webnotes.model import default_fields
- tax_master = webnotes.bean(tax_master_doctype, self.doc.fields.get(tax_master_field))
+ from frappe.model import default_fields
+ tax_master = frappe.bean(tax_master_doctype, self.doc.fields.get(tax_master_field))
for i, tax in enumerate(tax_master.doclist.get({"parentfield": tax_parentfield})):
for fieldname in default_fields:
@@ -375,7 +375,7 @@
def get_gl_dict(self, args):
"""this method populates the common properties of a gl entry record"""
- gl_dict = webnotes._dict({
+ gl_dict = frappe._dict({
'company': self.doc.company,
'posting_date': self.doc.posting_date,
'voucher_type': self.doc.doctype,
@@ -393,11 +393,11 @@
def clear_unallocated_advances(self, childtype, parentfield):
self.doclist.remove_items({"parentfield": parentfield, "allocated_amount": ["in", [0, None, ""]]})
- webnotes.conn.sql("""delete from `tab%s` where parentfield=%s and parent = %s
+ frappe.conn.sql("""delete from `tab%s` where parentfield=%s and parent = %s
and ifnull(allocated_amount, 0) = 0""" % (childtype, '%s', '%s'), (parentfield, self.doc.name))
def get_advances(self, account_head, child_doctype, parentfield, dr_or_cr):
- res = webnotes.conn.sql("""select t1.name as jv_no, t1.remark,
+ res = frappe.conn.sql("""select t1.name as jv_no, t1.remark,
t2.%s as amount, t2.name as jv_detail_no
from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
where t1.name = t2.parent and t2.account = %s and t2.is_advance = 'Yes'
@@ -426,13 +426,13 @@
for item in self.doclist.get({"parentfield": "entries"}):
if item.fields.get(item_ref_dn):
- ref_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
+ ref_amt = flt(frappe.conn.get_value(ref_dt + " Item",
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
if not ref_amt:
- webnotes.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
+ frappe.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
ref_dt + _(" is zero, system will not check for over-billed"))
else:
- already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
+ already_billed = frappe.conn.sql("""select sum(%s) from `tab%s`
where %s=%s and docstatus=1 and parent != %s""" %
(based_on, self.tname, item_ref_dn, '%s', '%s'),
(item.fields[item_ref_dn], self.doc.name))[0][0]
@@ -448,7 +448,7 @@
if total_billed_amt - max_allowed_amt > 0.01:
reduce_by = total_billed_amt - max_allowed_amt
- webnotes.throw(_("Row #") + cstr(item.idx) + ": " +
+ frappe.throw(_("Row #") + cstr(item.idx) + ": " +
_(" Max amount allowed for Item ") + cstr(item.item_code) +
_(" against ") + ref_dt + " " +
cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") +
@@ -468,7 +468,7 @@
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
if item_codes:
- stock_items = [r[0] for r in webnotes.conn.sql("""select name
+ stock_items = [r[0] for r in frappe.conn.sql("""select name
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
(", ".join((["%s"]*len(item_codes))),), item_codes)]
@@ -477,12 +477,12 @@
@property
def company_abbr(self):
if not hasattr(self, "_abbr"):
- self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
+ self._abbr = frappe.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr
def check_credit_limit(self, account):
- total_outstanding = webnotes.conn.sql("""
+ total_outstanding = frappe.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where account = %s""", account)
@@ -491,6 +491,6 @@
get_obj('Account', account).check_credit_limit(total_outstanding)
-@webnotes.whitelist()
+@frappe.whitelist()
def get_tax_rate(account_head):
- return webnotes.conn.get_value("Account", account_head, "tax_rate")
\ No newline at end of file
+ return frappe.conn.get_value("Account", account_head, "tax_rate")
\ No newline at end of file
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 7617685..21c85b7 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
-from webnotes import _, msgprint
-from webnotes.utils import flt, _round
+import frappe
+from frappe import _, msgprint
+from frappe.utils import flt, _round
from erpnext.setup.utils import get_company_currency
from erpnext.accounts.party import get_party_details
@@ -18,7 +18,7 @@
def validate(self):
super(BuyingController, self).validate()
if self.doc.supplier and not self.doc.supplier_name:
- self.doc.supplier_name = webnotes.conn.get_value("Supplier",
+ self.doc.supplier_name = frappe.conn.get_value("Supplier",
self.doc.supplier, "supplier_name")
self.is_item_table_empty()
self.validate_stock_or_nonstock_items()
@@ -41,7 +41,7 @@
def set_supplier_from_item_default(self):
if self.meta.get_field("supplier") and not self.doc.supplier:
for d in self.doclist.get({"doctype": self.tname}):
- supplier = webnotes.conn.get_value("Item", d.item_code, "default_supplier")
+ supplier = frappe.conn.get_value("Item", d.item_code, "default_supplier")
if supplier:
self.doc.supplier = supplier
break
@@ -61,10 +61,10 @@
self.doclist.get({"parentfield": "other_charges"})
if d.category in ["Valuation", "Valuation and Total"]]
if tax_for_valuation:
- webnotes.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1)
+ frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1)
def set_total_in_words(self):
- from webnotes.utils import money_in_words
+ from frappe.utils import money_in_words
company_currency = get_company_currency(self.doc.company)
if self.meta.get_field("in_words"):
self.doc.in_words = money_in_words(self.doc.grand_total, company_currency)
@@ -198,7 +198,7 @@
self.round_floats_in(item)
- item.conversion_factor = item.conversion_factor or flt(webnotes.conn.get_value(
+ item.conversion_factor = item.conversion_factor or flt(frappe.conn.get_value(
"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
"conversion_factor")) or 1
qty_in_stock_uom = flt(item.qty * item.conversion_factor)
@@ -209,12 +209,12 @@
def validate_for_subcontracting(self):
if not self.doc.is_subcontracted and self.sub_contracted_items:
- webnotes.msgprint(_("""Please enter whether %s is made for subcontracting or purchasing,
+ frappe.msgprint(_("""Please enter whether %s is made for subcontracting or purchasing,
in 'Is Subcontracted' field""" % self.doc.doctype), raise_exception=1)
if self.doc.doctype == "Purchase Receipt" and self.doc.is_subcontracted=="Yes" \
and not self.doc.supplier_warehouse:
- webnotes.msgprint(_("Supplier Warehouse mandatory subcontracted purchase receipt"),
+ frappe.msgprint(_("Supplier Warehouse mandatory subcontracted purchase receipt"),
raise_exception=1)
def update_raw_materials_supplied(self, raw_material_table):
@@ -256,7 +256,7 @@
d.rm_supp_cost = raw_materials_cost
def get_items_from_default_bom(self, item_code):
- bom_items = webnotes.conn.sql("""select t2.item_code, t2.qty_consumed_per_unit,
+ bom_items = frappe.conn.sql("""select t2.item_code, t2.qty_consumed_per_unit,
t2.rate, t2.stock_uom, t2.name, t2.description
from `tabBOM` t1, `tabBOM Item` t2
where t2.parent = t1.name and t1.item = %s and t1.is_default = 1
@@ -273,7 +273,7 @@
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
if item_codes:
- self._sub_contracted_items = [r[0] for r in webnotes.conn.sql("""select name
+ self._sub_contracted_items = [r[0] for r in frappe.conn.sql("""select name
from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \
(", ".join((["%s"]*len(item_codes))),), item_codes)]
@@ -286,7 +286,7 @@
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
if item_codes:
- self._purchase_items = [r[0] for r in webnotes.conn.sql("""select name
+ self._purchase_items = [r[0] for r in frappe.conn.sql("""select name
from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
(", ".join((["%s"]*len(item_codes))),), item_codes)]
@@ -295,4 +295,4 @@
def is_item_table_empty(self):
if not len(self.doclist.get({"parentfield": self.fname})):
- webnotes.throw(_("Item table can not be blank"))
\ No newline at end of file
+ frappe.throw(_("Item table can not be blank"))
\ No newline at end of file
diff --git a/erpnext/controllers/js/contact_address_common.js b/erpnext/controllers/js/contact_address_common.js
index 7c938d7..6a66469 100644
--- a/erpnext/controllers/js/contact_address_common.js
+++ b/erpnext/controllers/js/contact_address_common.js
@@ -14,7 +14,7 @@
}
if(doc.__islocal) {
- var last_route = wn.route_history.slice(-2, -1)[0];
+ var last_route = frappe.route_history.slice(-2, -1)[0];
if(last_route && last_route[0]==="Form") {
var doctype = last_route[1],
docname = last_route.slice(2).join("/");
@@ -23,7 +23,7 @@
"Installation Note", "Opportunity", "Customer Issue", "Maintenance Visit",
"Maintenance Schedule"]
.indexOf(doctype)!==-1) {
- var refdoc = wn.model.get_doc(doctype, docname);
+ var refdoc = frappe.model.get_doc(doctype, docname);
if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Customer" : true) {
cur_frm.set_value("customer", refdoc.customer || refdoc.name);
@@ -34,7 +34,7 @@
}
if(["Supplier", "Supplier Quotation", "Purchase Order", "Purchase Invoice", "Purchase Receipt"]
.indexOf(doctype)!==-1) {
- var refdoc = wn.model.get_doc(doctype, docname);
+ var refdoc = frappe.model.get_doc(doctype, docname);
cur_frm.set_value("supplier", refdoc.supplier || refdoc.name);
cur_frm.set_value("supplier_name", refdoc.supplier_name);
if(cur_frm.doc.doctype==="Address")
@@ -42,7 +42,7 @@
}
if(["Lead", "Quotation"]
.indexOf(doctype)!==-1) {
- var refdoc = wn.model.get_doc(doctype, docname);
+ var refdoc = frappe.model.get_doc(doctype, docname);
if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Lead" : true) {
cur_frm.set_value("lead", refdoc.lead || refdoc.name);
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 535ca3b..93efd43 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -2,8 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
-from webnotes.widgets.reportview import get_match_cond
+import frappe
+from frappe.widgets.reportview import get_match_cond
def get_filters_cond(doctype, filters, conditions):
if filters:
@@ -16,7 +16,7 @@
else:
flt.append([doctype, f[0], '=', f[1]])
- from webnotes.widgets.reportview import build_filter_conditions
+ from frappe.widgets.reportview import build_filter_conditions
build_filter_conditions(flt, conditions)
cond = ' and ' + ' and '.join(conditions)
else:
@@ -25,7 +25,7 @@
# searches for active employees
def employee_query(doctype, txt, searchfield, start, page_len, filters):
- return webnotes.conn.sql("""select name, employee_name from `tabEmployee`
+ return frappe.conn.sql("""select name, employee_name from `tabEmployee`
where status = 'Active'
and docstatus < 2
and (%(key)s like "%(txt)s"
@@ -40,7 +40,7 @@
# searches for leads which are not converted
def lead_query(doctype, txt, searchfield, start, page_len, filters):
- return webnotes.conn.sql("""select name, lead_name, company_name from `tabLead`
+ return frappe.conn.sql("""select name, lead_name, company_name from `tabLead`
where docstatus < 2
and ifnull(status, '') != 'Converted'
and (%(key)s like "%(txt)s"
@@ -57,7 +57,7 @@
# searches for customer
def customer_query(doctype, txt, searchfield, start, page_len, filters):
- cust_master_name = webnotes.defaults.get_user_default("cust_master_name")
+ cust_master_name = frappe.defaults.get_user_default("cust_master_name")
if cust_master_name == "Customer Name":
fields = ["name", "customer_group", "territory"]
@@ -66,7 +66,7 @@
fields = ", ".join(fields)
- return webnotes.conn.sql("""select %(field)s from `tabCustomer`
+ return frappe.conn.sql("""select %(field)s from `tabCustomer`
where docstatus < 2
and (%(key)s like "%(txt)s"
or customer_name like "%(txt)s")
@@ -81,14 +81,14 @@
# searches for supplier
def supplier_query(doctype, txt, searchfield, start, page_len, filters):
- supp_master_name = webnotes.defaults.get_user_default("supp_master_name")
+ supp_master_name = frappe.defaults.get_user_default("supp_master_name")
if supp_master_name == "Supplier Name":
fields = ["name", "supplier_type"]
else:
fields = ["name", "supplier_name", "supplier_type"]
fields = ", ".join(fields)
- return webnotes.conn.sql("""select %(field)s from `tabSupplier`
+ return frappe.conn.sql("""select %(field)s from `tabSupplier`
where docstatus < 2
and (%(key)s like "%(txt)s"
or supplier_name like "%(txt)s")
@@ -102,7 +102,7 @@
'page_len': page_len})
def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
- return webnotes.conn.sql("""select name, parent_account, debit_or_credit
+ return frappe.conn.sql("""select name, parent_account, debit_or_credit
from tabAccount
where tabAccount.docstatus!=2
and (account_type in (%s) or
@@ -117,11 +117,11 @@
filters.get("company"), "%%%s%%" % txt, start, page_len]))
def item_query(doctype, txt, searchfield, start, page_len, filters):
- from webnotes.utils import nowdate
+ from frappe.utils import nowdate
conditions = []
- return webnotes.conn.sql("""select tabItem.name,
+ return frappe.conn.sql("""select tabItem.name,
if(length(tabItem.item_name) > 40,
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
if(length(tabItem.description) > 40, \
@@ -145,7 +145,7 @@
def bom(doctype, txt, searchfield, start, page_len, filters):
conditions = []
- return webnotes.conn.sql("""select tabBOM.name, tabBOM.item
+ return frappe.conn.sql("""select tabBOM.name, tabBOM.item
from tabBOM
where tabBOM.docstatus=1
and tabBOM.is_active=1
@@ -160,7 +160,7 @@
if filters['customer']:
cond = '(`tabProject`.customer = "' + filters['customer'] + '" or ifnull(`tabProject`.customer,"")="") and'
- return webnotes.conn.sql("""select `tabProject`.name from `tabProject`
+ return frappe.conn.sql("""select `tabProject`.name from `tabProject`
where `tabProject`.status not in ("Completed", "Cancelled")
and %(cond)s `tabProject`.name like "%(txt)s" %(mcond)s
order by `tabProject`.name asc
@@ -168,7 +168,7 @@
'mcond':get_match_cond(doctype, searchfield),'start': start, 'page_len': page_len})
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
- return webnotes.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
+ return frappe.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
from `tabDelivery Note`
where `tabDelivery Note`.`%(key)s` like %(txt)s and
`tabDelivery Note`.docstatus = 1 %(fcond)s and
@@ -189,7 +189,7 @@
from erpnext.controllers.queries import get_match_cond
if filters.has_key('warehouse'):
- return webnotes.conn.sql("""select batch_no from `tabStock Ledger Entry` sle
+ return frappe.conn.sql("""select batch_no from `tabStock Ledger Entry` sle
where item_code = '%(item_code)s'
and warehouse = '%(warehouse)s'
and batch_no like '%(txt)s'
@@ -205,7 +205,7 @@
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),
'start': start, 'page_len': page_len})
else:
- return webnotes.conn.sql("""select name from tabBatch
+ return frappe.conn.sql("""select name from tabBatch
where docstatus != 2
and item = '%(item_code)s'
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 90ab919..5494011 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -2,10 +2,10 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
-from webnotes.utils import cint, flt, comma_or, _round, cstr
+import frappe
+from frappe.utils import cint, flt, comma_or, _round, cstr
from erpnext.setup.utils import get_company_currency
-from webnotes import msgprint, _
+from frappe import msgprint, _
from erpnext.controllers.stock_controller import StockController
@@ -20,7 +20,7 @@
check_active_sales_items(self)
def get_sender(self, comm):
- return webnotes.conn.get_value('Sales Email Settings', None, 'email_id')
+ return frappe.conn.get_value('Sales Email Settings', None, 'email_id')
def set_missing_values(self, for_validate=False):
super(SellingController, self).set_missing_values(for_validate)
@@ -45,7 +45,7 @@
def apply_shipping_rule(self):
if self.doc.shipping_rule:
- shipping_rule = webnotes.bean("Shipping Rule", self.doc.shipping_rule)
+ shipping_rule = frappe.bean("Shipping Rule", self.doc.shipping_rule)
value = self.doc.net_total
# TODO
@@ -68,10 +68,10 @@
})
def set_total_in_words(self):
- from webnotes.utils import money_in_words
+ from frappe.utils import money_in_words
company_currency = get_company_currency(self.doc.company)
- disable_rounded_total = cint(webnotes.conn.get_value("Global Defaults", None,
+ disable_rounded_total = cint(frappe.conn.get_value("Global Defaults", None,
"disable_rounded_total"))
if self.meta.get_field("in_words"):
@@ -264,24 +264,24 @@
_("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
def check_credit(self, grand_total):
- customer_account = webnotes.conn.get_value("Account", {"company": self.doc.company,
+ customer_account = frappe.conn.get_value("Account", {"company": self.doc.company,
"master_name": self.doc.customer}, "name")
if customer_account:
- total_outstanding = webnotes.conn.sql("""select
+ total_outstanding = frappe.conn.sql("""select
sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where account = %s""", customer_account)
total_outstanding = total_outstanding[0][0] if total_outstanding else 0
outstanding_including_current = flt(total_outstanding) + flt(grand_total)
- webnotes.bean('Account', customer_account).run_method("check_credit_limit",
+ frappe.bean('Account', customer_account).run_method("check_credit_limit",
outstanding_including_current)
def validate_max_discount(self):
for d in self.doclist.get({"parentfield": self.fname}):
- discount = flt(webnotes.conn.get_value("Item", d.item_code, "max_discount"))
+ discount = flt(frappe.conn.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.discount_percentage) > discount:
- webnotes.throw(_("You cannot give more than ") + cstr(discount) + "% " +
+ frappe.throw(_("You cannot give more than ") + cstr(discount) + "% " +
_("discount on Item Code") + ": " + cstr(d.item_code))
def get_item_list(self):
@@ -291,9 +291,9 @@
reserved_qty_for_main_item = 0
if self.doc.doctype == "Sales Order":
- if (webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
+ if (frappe.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
self.has_sales_bom(d.item_code)) and not d.warehouse:
- webnotes.throw(_("Please enter Reserved Warehouse for item ") +
+ frappe.throw(_("Please enter Reserved Warehouse for item ") +
d.item_code + _(" as it is stock Item or packing item"))
reserved_warehouse = d.warehouse
if flt(d.qty) > flt(d.delivered_qty):
@@ -316,7 +316,7 @@
for p in self.doclist.get({"parentfield": "packing_details"}):
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
# the packing details table's qty is already multiplied with parent's qty
- il.append(webnotes._dict({
+ il.append(frappe._dict({
'warehouse': p.warehouse,
'reserved_warehouse': reserved_warehouse,
'item_code': p.item_code,
@@ -328,7 +328,7 @@
'name': d.name
}))
else:
- il.append(webnotes._dict({
+ il.append(frappe._dict({
'warehouse': d.warehouse,
'reserved_warehouse': reserved_warehouse,
'item_code': d.item_code,
@@ -342,18 +342,18 @@
return il
def has_sales_bom(self, item_code):
- return webnotes.conn.sql("""select name from `tabSales BOM`
+ return frappe.conn.sql("""select name from `tabSales BOM`
where new_item_code=%s and docstatus != 2""", item_code)
def get_already_delivered_qty(self, dn, so, so_detail):
- qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Item`
+ qty = frappe.conn.sql("""select sum(qty) from `tabDelivery Note Item`
where prevdoc_detail_docname = %s and docstatus = 1
and against_sales_order = %s
and parent != %s""", (so_detail, so, dn))
return qty and flt(qty[0][0]) or 0.0
def get_so_qty_and_warehouse(self, so_detail):
- so_item = webnotes.conn.sql("""select qty, warehouse from `tabSales Order Item`
+ so_item = frappe.conn.sql("""select qty, warehouse from `tabSales Order Item`
where name = %s and docstatus = 1""", so_detail, as_dict=1)
so_qty = so_item and flt(so_item[0]["qty"]) or 0.0
so_warehouse = so_item and so_item[0]["warehouse"] or ""
@@ -362,20 +362,20 @@
def check_stop_sales_order(self, ref_fieldname):
for d in self.doclist.get({"parentfield": self.fname}):
if d.fields.get(ref_fieldname):
- status = webnotes.conn.get_value("Sales Order", d.fields[ref_fieldname], "status")
+ status = frappe.conn.get_value("Sales Order", d.fields[ref_fieldname], "status")
if status == "Stopped":
- webnotes.throw(self.doc.doctype +
+ frappe.throw(self.doc.doctype +
_(" can not be created/modified against stopped Sales Order ") +
d.fields[ref_fieldname])
def check_active_sales_items(obj):
for d in obj.doclist.get({"parentfield": obj.fname}):
if d.item_code:
- item = webnotes.conn.sql("""select docstatus, is_sales_item,
+ item = frappe.conn.sql("""select docstatus, is_sales_item,
is_service_item, income_account from tabItem where name = %s""",
d.item_code, as_dict=True)[0]
if item.is_sales_item == 'No' and item.is_service_item == 'No':
- webnotes.throw(_("Item is neither Sales nor Service Item") + ": " + d.item_code)
+ frappe.throw(_("Item is neither Sales nor Service Item") + ": " + d.item_code)
if d.income_account and not item.income_account:
- webnotes.conn.set_value("Item", d.item_code, "income_account",
+ frappe.conn.set_value("Item", d.item_code, "income_account",
d.income_account)
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 1743887..29cd490 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -2,11 +2,11 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
-from webnotes.utils import flt, cstr
-from webnotes import msgprint
+import frappe
+from frappe.utils import flt, cstr
+from frappe import msgprint
-from webnotes.model.controller import DocListController
+from frappe.model.controller import DocListController
status_map = {
"Contact": [
@@ -85,7 +85,7 @@
break
if update:
- webnotes.conn.set_value(self.doc.doctype, self.doc.name, "status", self.doc.status)
+ frappe.conn.set_value(self.doc.doctype, self.doc.name, "status", self.doc.status)
def on_communication(self):
self.communication_set = True
@@ -118,7 +118,7 @@
args['name'] = d.fields[args['join_field']]
# get all qty where qty > target_field
- item = webnotes.conn.sql("""select item_code, `%(target_ref_field)s`,
+ item = frappe.conn.sql("""select item_code, `%(target_ref_field)s`,
`%(target_field)s`, parenttype, parent from `tab%(target_dt)s`
where `%(target_ref_field)s` < `%(target_field)s`
and name="%(name)s" and docstatus=1""" % args, as_dict=1)
@@ -204,7 +204,7 @@
and (docstatus=1))""" % args
if args['detail_id']:
- webnotes.conn.sql("""update `tab%(target_dt)s`
+ frappe.conn.sql("""update `tab%(target_dt)s`
set %(target_field)s = (select sum(%(source_field)s)
from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s"
and (docstatus=1 %(cond)s)) %(second_source_condition)s
@@ -217,7 +217,7 @@
args['name'] = name
# update percent complete in the parent table
- webnotes.conn.sql("""update `tab%(target_parent_dt)s`
+ frappe.conn.sql("""update `tab%(target_parent_dt)s`
set %(target_parent_field)s = (select sum(if(%(target_ref_field)s >
ifnull(%(target_field)s, 0), %(target_field)s,
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
@@ -226,7 +226,7 @@
# update field
if args.get('status_field'):
- webnotes.conn.sql("""update `tab%(target_parent_dt)s`
+ frappe.conn.sql("""update `tab%(target_parent_dt)s`
set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001,
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
'Fully %(keyword)s', 'Partly %(keyword)s'))
@@ -236,7 +236,7 @@
def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
ref_fieldname = ref_dt.lower().replace(" ", "_")
zero_amount_refdoc = []
- all_zero_amount_refdoc = webnotes.conn.sql_list("""select name from `tab%s`
+ all_zero_amount_refdoc = frappe.conn.sql_list("""select name from `tab%s`
where docstatus=1 and net_total = 0""" % ref_dt)
for item in self.doclist.get({"parentfield": "entries"}):
@@ -250,24 +250,24 @@
def update_biling_status(self, zero_amount_refdoc, ref_dt, ref_fieldname):
for ref_dn in zero_amount_refdoc:
- ref_doc_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tab%s Item`
+ ref_doc_qty = flt(frappe.conn.sql("""select sum(ifnull(qty, 0)) from `tab%s Item`
where parent=%s""" % (ref_dt, '%s'), (ref_dn))[0][0])
- billed_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0))
+ billed_qty = flt(frappe.conn.sql("""select sum(ifnull(qty, 0))
from `tab%s Item` where %s=%s and docstatus=1""" %
(self.doc.doctype, ref_fieldname, '%s'), (ref_dn))[0][0])
per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\
/ ref_doc_qty)*100
- webnotes.conn.set_value(ref_dt, ref_dn, "per_billed", per_billed)
+ frappe.conn.set_value(ref_dt, ref_dn, "per_billed", per_billed)
- from webnotes.model.meta import has_field
+ from frappe.model.meta import has_field
if has_field(ref_dt, "billing_status"):
if per_billed < 0.001: billing_status = "Not Billed"
elif per_billed >= 99.99: billing_status = "Fully Billed"
else: billing_status = "Partly Billed"
- webnotes.conn.set_value(ref_dt, ref_dn, "billing_status", billing_status)
+ frappe.conn.set_value(ref_dt, ref_dn, "billing_status", billing_status)
def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None):
"""
@@ -276,11 +276,11 @@
if item_tolerance.get(item_code):
return item_tolerance[item_code], item_tolerance, global_tolerance
- tolerance = flt(webnotes.conn.get_value('Item',item_code,'tolerance') or 0)
+ tolerance = flt(frappe.conn.get_value('Item',item_code,'tolerance') or 0)
if not tolerance:
if global_tolerance == None:
- global_tolerance = flt(webnotes.conn.get_value('Global Defaults', None,
+ global_tolerance = flt(frappe.conn.get_value('Global Defaults', None,
'tolerance'))
tolerance = global_tolerance
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index eff6491..5b542bd 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -2,10 +2,10 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
-from webnotes.utils import cint, flt, cstr
-from webnotes import msgprint, _
-import webnotes.defaults
+import frappe
+from frappe.utils import cint, flt, cstr
+from frappe import msgprint, _
+import frappe.defaults
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries
@@ -15,7 +15,7 @@
if self.doc.docstatus == 2:
delete_gl_entries(voucher_type=self.doc.doctype, voucher_no=self.doc.name)
- if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
+ if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
warehouse_account = self.get_warehouse_account()
if self.doc.docstatus==1:
@@ -74,7 +74,7 @@
for d in details:
self.check_expense_account(d)
else:
- details = [webnotes._dict({
+ details = [frappe._dict({
"name":d,
"expense_account": default_expense_account,
"cost_center": default_cost_center
@@ -84,14 +84,14 @@
def get_stock_ledger_details(self):
stock_ledger = {}
- for sle in webnotes.conn.sql("""select warehouse, stock_value_difference, voucher_detail_no
+ for sle in frappe.conn.sql("""select warehouse, stock_value_difference, voucher_detail_no
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
(self.doc.doctype, self.doc.name), as_dict=True):
stock_ledger.setdefault(sle.voucher_detail_no, []).append(sle)
return stock_ledger
def get_warehouse_account(self):
- warehouse_account = dict(webnotes.conn.sql("""select master_name, name from tabAccount
+ warehouse_account = dict(frappe.conn.sql("""select master_name, name from tabAccount
where account_type = 'Warehouse' and ifnull(master_name, '') != ''"""))
return warehouse_account
@@ -102,7 +102,7 @@
warehouse_account = self.get_warehouse_account()
for voucher_type, voucher_no in future_stock_vouchers:
existing_gle = gle.get((voucher_type, voucher_no), [])
- voucher_obj = webnotes.get_obj(voucher_type, voucher_no)
+ voucher_obj = frappe.get_obj(voucher_type, voucher_no)
expected_gle = voucher_obj.get_gl_entries(warehouse_account)
if expected_gle:
matched = True
@@ -134,7 +134,7 @@
else:
condition = ""
- for d in webnotes.conn.sql("""select distinct sle.voucher_type, sle.voucher_no
+ for d in frappe.conn.sql("""select distinct sle.voucher_type, sle.voucher_no
from `tabStock Ledger Entry` sle
where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) %s
order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" %
@@ -147,7 +147,7 @@
def get_voucherwise_gl_entries(self, future_stock_vouchers):
gl_entries = {}
if future_stock_vouchers:
- for d in webnotes.conn.sql("""select * from `tabGL Entry`
+ for d in frappe.conn.sql("""select * from `tabGL Entry`
where posting_date >= %s and voucher_no in (%s)""" %
('%s', ', '.join(['%s']*len(future_stock_vouchers))),
tuple([self.doc.posting_date] + [d[1] for d in future_stock_vouchers]), as_dict=1):
@@ -156,7 +156,7 @@
return gl_entries
def delete_gl_entries(self, voucher_type, voucher_no):
- webnotes.conn.sql("""delete from `tabGL Entry`
+ frappe.conn.sql("""delete from `tabGL Entry`
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
def make_adjustment_entry(self, expected_gle, voucher_obj):
@@ -236,7 +236,7 @@
item_list, warehouse_list = self.get_distinct_item_warehouse()
if item_list and warehouse_list:
- res = webnotes.conn.sql("""select item_code, voucher_type, voucher_no,
+ res = frappe.conn.sql("""select item_code, voucher_type, voucher_no,
voucher_detail_no, posting_date, posting_time, stock_value,
warehouse, actual_qty as qty from `tabStock Ledger Entry`
where company = %s and item_code in (%s) and warehouse in (%s)
@@ -264,6 +264,6 @@
return list(set(item_list)), list(set(warehouse_list))
def make_cancel_gl_entries(self):
- if webnotes.conn.sql("""select name from `tabGL Entry` where voucher_type=%s
+ if frappe.conn.sql("""select name from `tabGL Entry` where voucher_type=%s
and voucher_no=%s""", (self.doc.doctype, self.doc.name)):
self.make_gl_entries()
\ No newline at end of file
diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py
index 7559b1f..9bc259c 100644
--- a/erpnext/controllers/trends.py
+++ b/erpnext/controllers/trends.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 add_days, add_months, cstr, getdate
-from webnotes import _
+import frappe
+from frappe.utils import add_days, add_months, cstr, getdate
+from frappe import _
def get_columns(filters, trans):
validate_filters(filters)
@@ -30,10 +30,10 @@
def validate_filters(filters):
for f in ["Fiscal Year", "Based On", "Period", "Company"]:
if not filters.get(f.lower().replace(" ", "_")):
- webnotes.msgprint(f + _(" is mandatory"), raise_exception=1)
+ frappe.msgprint(f + _(" is mandatory"), raise_exception=1)
if filters.get("based_on") == filters.get("group_by"):
- webnotes.msgprint("'Based On' and 'Group By' can not be same", raise_exception=1)
+ frappe.msgprint("'Based On' and 'Group By' can not be same", raise_exception=1)
def get_data(filters, conditions):
data = []
@@ -58,7 +58,7 @@
inc = 2
else :
inc = 1
- data1 = webnotes.conn.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
+ data1 = frappe.conn.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and
t1.docstatus = 1 %s
group by %s
@@ -73,7 +73,7 @@
data.append(dt)
#to get distinct value of col specified by group_by in filter
- row = webnotes.conn.sql("""select DISTINCT(%s) from `tab%s` t1, `tab%s Item` t2 %s
+ row = frappe.conn.sql("""select DISTINCT(%s) from `tab%s` t1, `tab%s Item` t2 %s
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
and t1.docstatus = 1 and %s = %s
""" %
@@ -85,7 +85,7 @@
des = ['' for q in range(len(conditions["columns"]))]
#get data for group_by filter
- row1 = webnotes.conn.sql(""" select %s , %s from `tab%s` t1, `tab%s Item` t2 %s
+ row1 = frappe.conn.sql(""" select %s , %s from `tab%s` t1, `tab%s Item` t2 %s
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
and t1.docstatus = 1 and %s = %s and %s = %s
""" %
@@ -101,7 +101,7 @@
data.append(des)
else:
- data = webnotes.conn.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
+ data = frappe.conn.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and
t1.docstatus = 1 %s
group by %s
@@ -151,12 +151,12 @@
""" % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
return query_details
-@webnotes.whitelist(allow_guest=True)
+@frappe.whitelist(allow_guest=True)
def get_period_date_ranges(period, fiscal_year=None, year_start_date=None):
from dateutil.relativedelta import relativedelta
if not year_start_date:
- year_start_date, year_end_date = webnotes.conn.get_value("Fiscal Year",
+ year_start_date, year_end_date = frappe.conn.get_value("Fiscal Year",
fiscal_year, ["year_start_date", "year_end_date"])
increment = {
@@ -249,7 +249,7 @@
based_on_details["based_on_group_by"] = 't2.project_name'
based_on_details["addl_tables"] = ''
else:
- webnotes.msgprint("Project-wise data is not available for Quotation", raise_exception=1)
+ frappe.msgprint("Project-wise data is not available for Quotation", raise_exception=1)
return based_on_details