From eaed03d010030c831204b6df8cc9a0a42dc2666c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 30 Nov 2012 17:24:54 +0530 Subject: [PATCH] replaced convert_to_lists --- buying/doctype/supplier/supplier.py | 2 +- home/doctype/home_control/home_control.py | 12 ++++++------ .../monthly_salary_register.py | 4 ++-- .../doctype/project_control/project_control.py | 4 ++-- selling/doctype/plot_control/plot_control.py | 18 +++++++++--------- setup/doctype/sales_partner/sales_partner.py | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 0251899f79..0e28f1fbff 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -127,7 +127,7 @@ class DocType(TransactionBase): def get_contacts(self,nm): if nm: - contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm)) + contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm)) return contact_details else: diff --git a/home/doctype/home_control/home_control.py b/home/doctype/home_control/home_control.py index c20010953d..75ab2222ce 100644 --- a/home/doctype/home_control/home_control.py +++ b/home/doctype/home_control/home_control.py @@ -238,14 +238,14 @@ class DocType: # ------------------------------------------------------------------------------------------------------- def get_todo_reminder(self): - return convert_to_lists(sql("select name, description, date, priority,checked from `tabToDo` where owner=%s and date=%s and checked=1 order by priority, date", (session['user'], nowdate()))) + return webnotes.conn.convert_to_lists(sql("select name, description, date, priority,checked from `tabToDo` where owner=%s and date=%s and checked=1 order by priority, date", (session['user'], nowdate()))) # get user details def get_users(self): ret = {} - ret['usr'] = convert_to_lists(sql("select distinct name, concat_ws(' ', first_name, last_name), ifnull(messanger_status,'Available') from tabProfile where name=%s", session['user'])) - ret['on'] = convert_to_lists(sql("select distinct t1.name, concat_ws(' ', t1.first_name, t1.last_name), ifnull(t1.messanger_status,'Available') from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest',%s) and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1", session['user'])) - ret['off'] = convert_to_lists(sql("select distinct t1.name, concat_ws(' ', t1.first_name, t1.last_name), ifnull(t1.messanger_status,'Offline') from tabProfile t1, tabSessions t2 where t1.name != t2.user and t1.name not in('Guest',%s) and t1.name not in(select distinct t1.name from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest',%s) and (t1.messanger_status !='Invisible' or t1.messanger_status is null) and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1)", (session['user'], session['user']))) + ret['usr'] = webnotes.conn.convert_to_lists(sql("select distinct name, concat_ws(' ', first_name, last_name), ifnull(messanger_status,'Available') from tabProfile where name=%s", session['user'])) + ret['on'] = webnotes.conn.convert_to_lists(sql("select distinct t1.name, concat_ws(' ', t1.first_name, t1.last_name), ifnull(t1.messanger_status,'Available') from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest',%s) and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1", session['user'])) + ret['off'] = webnotes.conn.convert_to_lists(sql("select distinct t1.name, concat_ws(' ', t1.first_name, t1.last_name), ifnull(t1.messanger_status,'Offline') from tabProfile t1, tabSessions t2 where t1.name != t2.user and t1.name not in('Guest',%s) and t1.name not in(select distinct t1.name from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest',%s) and (t1.messanger_status !='Invisible' or t1.messanger_status is null) and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1)", (session['user'], session['user']))) return ret @@ -268,7 +268,7 @@ class DocType: show_list = ['Home','Setup','Accounts','Selling','Buying','Support','Stock','HR','Projects','Analysis','Production'] ml = filter(lambda x: x[0] in show_list, \ sql("select name, module_label, module_seq, is_hidden from `tabModule Def` where docstatus<2 order by module_seq asc, module_label asc")) - return convert_to_lists(ml) + return webnotes.conn.convert_to_lists(ml) def set_module_order(self,arg): arg = eval(arg) @@ -278,7 +278,7 @@ class DocType: # ------------------------------------------------------------------------------------------------------- def get_bd_list(self): - bl = convert_to_lists(sql("select name,concat_ws(' ',first_name,last_name),birth_date from tabProfile where (birth_date is not null and birth_date != '') and (enabled is not null and enabled !='')")) + bl = webnotes.conn.convert_to_lists(sql("select name,concat_ws(' ',first_name,last_name),birth_date from tabProfile where (birth_date is not null and birth_date != '') and (enabled is not null and enabled !='')")) nd = nowdate().split('-') d = cint(nd[2]) diff --git a/hr/search_criteria/monthly_salary_register/monthly_salary_register.py b/hr/search_criteria/monthly_salary_register/monthly_salary_register.py index b22c32aecc..5171aa45d5 100644 --- a/hr/search_criteria/monthly_salary_register/monthly_salary_register.py +++ b/hr/search_criteria/monthly_salary_register/monthly_salary_register.py @@ -44,8 +44,8 @@ for r in res: for d1 in li: d2 = '%s'%d1 - earn_ret=convert_to_lists(sql("select e_type,e_amount from `tabSalary Slip Earning` where parent = '%s'"%r[col_idx['ID']])) - ded_ret=convert_to_lists(sql("select d_type,d_amount from `tabSalary Slip Deduction` where parent = '%s'"%r[col_idx['ID']])) + earn_ret=webnotes.conn.convert_to_lists(sql("select e_type,e_amount from `tabSalary Slip Earning` where parent = '%s'"%r[col_idx['ID']])) + ded_ret=webnotes.conn.convert_to_lists(sql("select d_type,d_amount from `tabSalary Slip Deduction` where parent = '%s'"%r[col_idx['ID']])) for e in earn_ret: diff --git a/projects/doctype/project_control/project_control.py b/projects/doctype/project_control/project_control.py index 5601837614..d11b260b88 100644 --- a/projects/doctype/project_control/project_control.py +++ b/projects/doctype/project_control/project_control.py @@ -54,7 +54,7 @@ class DocType: pl.append(p4['name']) # milestones in the next 7 days for active projects - ml = convert_to_lists(sql("select t1.milestone_date, t1.milestone, t1.parent from `tabProject Milestone` t1, tabProject t2 where t1.parent = t2.name and t2.status='Open' and DATEDIFF(t1.milestone_date, CURDATE()) BETWEEN 0 AND 7 ORDER BY t1.milestone_date ASC")) + ml = webnotes.conn.convert_to_lists(sql("select t1.milestone_date, t1.milestone, t1.parent from `tabProject Milestone` t1, tabProject t2 where t1.parent = t2.name and t2.status='Open' and DATEDIFF(t1.milestone_date, CURDATE()) BETWEEN 0 AND 7 ORDER BY t1.milestone_date ASC")) # percent of activity completed per project comp = {} @@ -112,7 +112,7 @@ class DocType: (exp_end_date between '%(st)s' and '%(end)s') or (exp_start_date < '%(st)s' and exp_end_date > '%(end)s')) %(cond)s order by exp_start_date limit 100""" % {'st': start_date, 'end': end_date, 'cond':cl}) - return convert_to_lists(tl) + return webnotes.conn.convert_to_lists(tl) def declare_proj_completed(self, arg): chk = sql("select name from `tabTask` where project=%s and status='Open'", arg) diff --git a/selling/doctype/plot_control/plot_control.py b/selling/doctype/plot_control/plot_control.py index 55d3730e10..7823b7346d 100644 --- a/selling/doctype/plot_control/plot_control.py +++ b/selling/doctype/plot_control/plot_control.py @@ -33,9 +33,9 @@ class DocType: def get_monthwise_amount(self,lst): lst = lst.split(',') if not lst[1]: - ret = convert_to_lists(sql("SELECT SUM(grand_total) AMOUNT,CASE MONTH(due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME FROM `tabSales Invoice` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY MONTH(due_date) ORDER BY MONTH(due_date)"%lst[0])) + ret = webnotes.conn.convert_to_lists(sql("SELECT SUM(grand_total) AMOUNT,CASE MONTH(due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME FROM `tabSales Invoice` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY MONTH(due_date) ORDER BY MONTH(due_date)"%lst[0])) else: - ret = convert_to_lists(sql("select sum(t2.amount) AMOUNT ,CASE MONTH(t1.due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME from `tabSales Invoice` t1,`tabSales Invoice Item` t2 WHERE t1.name = t2.parent and t1.docstatus = 1 and t2.item_group = '%s' AND t1.fiscal_year = '%s' GROUP BY MONTH(t1.due_date) ORDER BY MONTH(t1.due_date)"%(lst[1],lst[0]))) + ret = webnotes.conn.convert_to_lists(sql("select sum(t2.amount) AMOUNT ,CASE MONTH(t1.due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME from `tabSales Invoice` t1,`tabSales Invoice Item` t2 WHERE t1.name = t2.parent and t1.docstatus = 1 and t2.item_group = '%s' AND t1.fiscal_year = '%s' GROUP BY MONTH(t1.due_date) ORDER BY MONTH(t1.due_date)"%(lst[1],lst[0]))) m =cint(sql("select month('%s')"%(get_defaults()['year_start_date']))[0][0]) @@ -62,13 +62,13 @@ class DocType: if not lst[2]: query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+ cases +"END Weekly FROM `tabSales Invoice` WHERE MONTH(due_date) = %d AND docstatus = 1 AND fiscal_year = '%s' GROUP BY Weekly ORDER BY Weekly" - ret = convert_to_lists(sql(query%(cint(lst[0]),lst[1]))) + ret = webnotes.conn.convert_to_lists(sql(query%(cint(lst[0]),lst[1]))) else: query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly FROM `tabSales Invoice` t1, `tabSales Invoice Item` t2 WHERE MONTH(t1.due_date) = %d AND t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly" - ret =convert_to_lists(sql(query%(cint(lst[0]),lst[1],lst[2]))) + ret =webnotes.conn.convert_to_lists(sql(query%(cint(lst[0]),lst[1],lst[2]))) return ret and ret or '' #================================================================================ @@ -106,12 +106,12 @@ class DocType: if not lst[1]: query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+cases+"END Weekly, month(due_date) month FROM `tabSales Invoice` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY `month`,weekly ORDER BY `month`,weekly" - ret = convert_to_lists(sql(query%lst[0])) + ret = webnotes.conn.convert_to_lists(sql(query%lst[0])) else: query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly, month(due_date) month FROM `tabSales Invoice` t1, `tabSales Invoice Item` t2 WHERE t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly" - ret = convert_to_lists(sql(query%(lst[0],lst[1]))) + ret = webnotes.conn.convert_to_lists(sql(query%(lst[0],lst[1]))) return ret and ret or '' @@ -228,10 +228,10 @@ class DocType: return d def get_item_groups(self): - ret = convert_to_lists(sql("select name from `tabItem Group` where docstatus != 2 and is_group = 'No'")) - #ret = convert_to_lists(sql("select item_group from `tabItem` where is_sales_item='Yes' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) and item_group !=''")) + ret = webnotes.conn.convert_to_lists(sql("select name from `tabItem Group` where docstatus != 2 and is_group = 'No'")) + #ret = webnotes.conn.convert_to_lists(sql("select item_group from `tabItem` where is_sales_item='Yes' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) and item_group !=''")) return ret and ret or '' def get_fiscal_year(self): - ret = convert_to_lists(sql("select name from `tabFiscal Year` where docstatus =0")) + ret = webnotes.conn.convert_to_lists(sql("select name from `tabFiscal Year` where docstatus =0")) return ret and ret or '' \ No newline at end of file diff --git a/setup/doctype/sales_partner/sales_partner.py b/setup/doctype/sales_partner/sales_partner.py index f332196c1c..f99833e16b 100644 --- a/setup/doctype/sales_partner/sales_partner.py +++ b/setup/doctype/sales_partner/sales_partner.py @@ -48,7 +48,7 @@ class DocType: def get_contacts(self,nm): if nm: - contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm)) + contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm)) return contact_details else: return '' \ No newline at end of file