-webnotes +frappe 💥

This commit is contained in:
Rushabh Mehta
2014-02-14 15:47:51 +05:30
parent 8ae051cb39
commit 793ba6bd37
729 changed files with 5194 additions and 9971 deletions

View File

@@ -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 get_columns(filters, trans):
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 @@ def get_data(filters, conditions):
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 @@ def get_data(filters, conditions):
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 @@ def get_data(filters, conditions):
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 @@ def get_data(filters, conditions):
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 @@ def get_period_wise_query(bet_dates, trans_date, query_details):
""" % {"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 @@ def based_wise_colums_query(based_on, trans):
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