From 16447005bf6f51f883372758c2606ee0be1c0e3d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Sep 2013 16:58:54 +0530 Subject: [PATCH 1/5] [fix] [minor] fixes in old patch --- patches/december_2012/address_title.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/patches/december_2012/address_title.py b/patches/december_2012/address_title.py index fc7d2baed1..13dd74d896 100644 --- a/patches/december_2012/address_title.py +++ b/patches/december_2012/address_title.py @@ -9,9 +9,6 @@ def execute(): webnotes.conn.sql("""update tabAddress set address_title = customer_name where ifnull(customer_name,'')!=''""") webnotes.conn.sql("""update tabAddress set address_title = supplier_name where ifnull(supplier_name,'')!=''""") webnotes.conn.sql("""update tabAddress set address_title = sales_partner where ifnull(sales_partner,'')!=''""") - - webnotes.reload_doc("website", "doctype", "product_settings") - webnotes.reset_perms("Product Settings") # move code to new doctype webnotes.conn.set_value("Website Script", None, "javascript", From 94d62a8d9f5aa76f008d0d6f820e3261876a6762 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Sep 2013 17:39:36 +0530 Subject: [PATCH 2/5] [minor] [patch] fixed old patch --- .../p03_buying_selling_for_price_list.py | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py index c71646a8f5..c5a143511c 100644 --- a/patches/june_2013/p03_buying_selling_for_price_list.py +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -3,19 +3,24 @@ import webnotes from webnotes.utils import cint +import MySQLdb def execute(): webnotes.reload_doc("setup", "doctype", "price_list") webnotes.reload_doc("stock", "doctype", "item_price") - for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): - buying, selling = False, False - for b, s in webnotes.conn.sql("""select distinct buying, selling - from `tabItem Price` where price_list_name=%s""", price_list): - buying = buying or cint(b) - selling = selling or cint(s) + try: + for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): + buying, selling = False, False + for b, s in webnotes.conn.sql("""select distinct buying, selling + from `tabItem Price` where price_list_name=%s""", price_list): + buying = buying or cint(b) + selling = selling or cint(s) - buying_or_selling = "Selling" if selling else "Buying" - webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) - webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s - where price_list_name=%s""", (buying_or_selling, price_list)) + buying_or_selling = "Selling" if selling else "Buying" + webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s + where price_list_name=%s""", (buying_or_selling, price_list)) + except MySQLdb.OperationalError, e: + if e.args[0] == 1054: + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling="Selling" """) From 31f1f005dd67ac7c304c2191c230e6bb34c35a0a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Sep 2013 17:43:38 +0530 Subject: [PATCH 3/5] [minor] [patch] fixed old patch --- .../p03_buying_selling_for_price_list.py | 3 ++ .../p01_update_communication.py | 29 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py index c5a143511c..931517ea1a 100644 --- a/patches/june_2013/p03_buying_selling_for_price_list.py +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -1,6 +1,7 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # License: GNU General Public License v3. See license.txt +from __future__ import unicode_literals import webnotes from webnotes.utils import cint import MySQLdb @@ -24,3 +25,5 @@ def execute(): except MySQLdb.OperationalError, e: if e.args[0] == 1054: webnotes.conn.sql("""update `tabItem Price` set buying_or_selling="Selling" """) + else: + raise e diff --git a/patches/september_2013/p01_update_communication.py b/patches/september_2013/p01_update_communication.py index d840c801f9..31317384a2 100644 --- a/patches/september_2013/p01_update_communication.py +++ b/patches/september_2013/p01_update_communication.py @@ -1,15 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals import webnotes +import MySQLdb def execute(): + webnotes.reload_doc("core", "doctype", "communication") + webnotes.conn.sql("""update tabCommunication set communication_date = creation where + ifnull(communication_date, '')='' """) + for doctype in ("Contact", "Lead", "Job Applicant", "Supplier", "Customer", "Quotation", "Sales Person", "Support Ticket"): - fieldname = doctype.replace(" ", '_').lower() - webnotes.conn.sql("""update tabCommunication - set parenttype=%s, parentfield='communications', - parent=`%s` - where ifnull(`%s`, '')!=''""" % ("%s", fieldname, fieldname), doctype) - - webnotes.reload_doc("core", "doctype", "communication") - - webnotes.conn.sql("""update tabCommunication set communication_date = creation where - ifnull(communication_date, '')='' """) - \ No newline at end of file + try: + fieldname = doctype.replace(" ", '_').lower() + webnotes.conn.sql("""update tabCommunication + set parenttype=%s, parentfield='communications', + parent=`%s` + where ifnull(`%s`, '')!=''""" % ("%s", fieldname, fieldname), doctype) + except MySQLdb.OperationalError, e: + if e.args[0] != 1054: + raise e From 24416f92cc6cadb07d3dbc7fb7fd81fe6519785e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Sep 2013 18:35:23 +0530 Subject: [PATCH 4/5] [fix] [minor] Set Purchase Order Date as No Copy --- buying/doctype/purchase_order/purchase_order.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt index 1134d95504..d3c1620b51 100644 --- a/buying/doctype/purchase_order/purchase_order.txt +++ b/buying/doctype/purchase_order/purchase_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:39", "docstatus": 0, - "modified": "2013-08-09 14:45:51", + "modified": "2013-09-12 18:34:54", "modified_by": "Administrator", "owner": "Administrator" }, @@ -132,6 +132,7 @@ "fieldtype": "Date", "in_filter": 1, "label": "Purchase Order Date", + "no_copy": 1, "oldfieldname": "transaction_date", "oldfieldtype": "Date", "reqd": 1, From 3a6f4f882af0849678759c02dda37c890fd64e2b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Sep 2013 19:10:05 +0530 Subject: [PATCH 5/5] [fix] [minor] communication related cleanup --- buying/doctype/supplier/supplier.py | 12 ++++-------- hr/doctype/job_applicant/job_applicant.py | 7 +------ install_erpnext.py | 1 + selling/doctype/customer/customer.py | 11 +++-------- selling/doctype/lead/lead.py | 1 - selling/doctype/quotation/quotation.py | 5 ----- utilities/doctype/contact/contact.py | 2 -- 7 files changed, 9 insertions(+), 30 deletions(-) diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 75b2e03762..ccdeae9c65 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -132,14 +132,10 @@ class DocType(TransactionBase): sql("delete from `tabAddress` where name=%s",(rec['name'])) def delete_supplier_contact(self): - for rec in sql("select * from `tabContact` where supplier=%s", (self.doc.name,), as_dict=1): - sql("delete from `tabContact` where name=%s",(rec['name'])) - - def delete_supplier_communication(self): - webnotes.conn.sql("""\ - delete from `tabCommunication` - where supplier = %s and customer is null""", self.doc.name) - + for contact in webnotes.conn.sql_list("""select name from `tabContact` + where supplier=%s""", self.doc.name): + webnotes.delete_doc("Contact", contact) + def delete_supplier_account(self): """delete supplier's ledger if exist and check balance before deletion""" acc = sql("select name from `tabAccount` where master_type = 'Supplier' \ diff --git a/hr/doctype/job_applicant/job_applicant.py b/hr/doctype/job_applicant/job_applicant.py index 99272303d0..9bf1b967e7 100644 --- a/hr/doctype/job_applicant/job_applicant.py +++ b/hr/doctype/job_applicant/job_applicant.py @@ -21,9 +21,4 @@ class DocType(TransactionBase): else: status = "Open" - webnotes.conn.set(self.doc, 'status', status) - - def on_trash(self): - webnotes.conn.sql("""delete from `tabCommunication` - where job_applicant=%s""", self.doc.name) - \ No newline at end of file + webnotes.conn.set(self.doc, 'status', status) \ No newline at end of file diff --git a/install_erpnext.py b/install_erpnext.py index c57a9e2e7f..70cc2aaa91 100644 --- a/install_erpnext.py +++ b/install_erpnext.py @@ -149,6 +149,7 @@ def install_python_modules(): exec_in_shell("easy_install pip") exec_in_shell("pip install --upgrade pip") + exec_in_shell("pip install --upgrade setuptools") exec_in_shell("pip install --upgrade virtualenv") exec_in_shell("pip install -q %s" % python_modules) diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index fb3c0062a7..d3a263fbb9 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -126,14 +126,10 @@ class DocType(TransactionBase): webnotes.conn.sql("""delete from `tabAddress` where name=%s""", name) def delete_customer_contact(self): - for rec in sql("select * from `tabContact` where customer=%s", (self.doc.name,), as_dict=1): - sql("delete from `tabContact` where name=%s",(rec['name'])) + for contact in webnotes.conn.sql_list("""select name from `tabContact` + where customer=%s""", self.doc.name): + webnotes.delete_doc("Contact", contact) - def delete_customer_communication(self): - webnotes.conn.sql("""\ - delete from `tabCommunication` - where customer = %s and supplier is null""", self.doc.name) - def delete_customer_account(self): """delete customer's ledger if exist and check balance before deletion""" acc = sql("select name from `tabAccount` where master_type = 'Customer' \ @@ -145,7 +141,6 @@ class DocType(TransactionBase): def on_trash(self): self.delete_customer_address() self.delete_customer_contact() - self.delete_customer_communication() self.delete_customer_account() if self.doc.lead_name: sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name) diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py index 1aff8c865c..da11410f24 100644 --- a/selling/doctype/lead/lead.py +++ b/selling/doctype/lead/lead.py @@ -80,7 +80,6 @@ class DocType(SellingController): return webnotes.conn.get_value('Sales Email Settings',None,'email_id') def on_trash(self): - webnotes.conn.sql("""update tabCommunication set lead=null where lead=%s""", self.doc.name) webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""", self.doc.name) diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py index 588d8d6e1f..44a67fa45c 100644 --- a/selling/doctype/quotation/quotation.py +++ b/selling/doctype/quotation/quotation.py @@ -204,11 +204,6 @@ class DocType(SellingController): print_lst.append(lst1) return print_lst - def update_followup_details(self): - sql("delete from `tabCommunication Log` where parent = '%s'"%self.doc.name) - for d in getlist(self.doclist, 'follow_up'): - d.save() - @webnotes.whitelist() def make_sales_order(source_name, target_doclist=None): return _make_sales_order(source_name, target_doclist) diff --git a/utilities/doctype/contact/contact.py b/utilities/doctype/contact/contact.py index a116edbdc2..84c8a59de8 100644 --- a/utilities/doctype/contact/contact.py +++ b/utilities/doctype/contact/contact.py @@ -55,7 +55,5 @@ class DocType(TransactionBase): self.doc.is_primary_contact = 1 def on_trash(self): - webnotes.conn.sql("""update tabCommunication set contact='' where contact=%s""", - self.doc.name) webnotes.conn.sql("""update `tabSupport Ticket` set contact='' where contact=%s""", self.doc.name) \ No newline at end of file