From 6a589be1c5d57467a4b83b49232922192083e09b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Oct 2013 10:54:59 +0530 Subject: [PATCH 01/10] [patch] remove sales and purchase return tool --- .../march_2013/p06_remove_sales_purchase_return_tool.py | 6 ++++-- .../p03_remove_sales_and_purchase_return_tool.py | 8 ++++++++ patches/patch_list.py | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 patches/october_2013/p03_remove_sales_and_purchase_return_tool.py diff --git a/patches/march_2013/p06_remove_sales_purchase_return_tool.py b/patches/march_2013/p06_remove_sales_purchase_return_tool.py index ed8fbc87fd..ac11eccc0a 100644 --- a/patches/march_2013/p06_remove_sales_purchase_return_tool.py +++ b/patches/march_2013/p06_remove_sales_purchase_return_tool.py @@ -4,5 +4,7 @@ import webnotes def execute(): - webnotes.delete_doc("DocType", "Sales and Purchase Return Item") - webnotes.delete_doc("DocType", "Sales and Purchase Return Tool") \ No newline at end of file + if webnotes.conn.exists("DocType", "Sales and Purchase Return Item"): + webnotes.delete_doc("DocType", "Sales and Purchase Return Item") + if webnotes.conn.exists("DocType", "Sales and Purchase Return Tool"): + webnotes.delete_doc("DocType", "Sales and Purchase Return Tool") \ No newline at end of file diff --git a/patches/october_2013/p03_remove_sales_and_purchase_return_tool.py b/patches/october_2013/p03_remove_sales_and_purchase_return_tool.py new file mode 100644 index 0000000000..e0965ab0a0 --- /dev/null +++ b/patches/october_2013/p03_remove_sales_and_purchase_return_tool.py @@ -0,0 +1,8 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +def execute(): + from patches.march_2013 import p06_remove_sales_purchase_return_tool + p06_remove_sales_purchase_return_tool.execute() \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 0b27a2e0d8..e353ab628a 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -224,4 +224,5 @@ patch_list = [ "patches.october_2013.repost_planned_qty", "patches.october_2013.p02_update_price_list_and_item_details_in_item_price", "execute:webnotes.delete_doc('Report', 'Item-wise Price List')", + "patches.october_2013.p03_remove_sales_and_purchase_return_tool", ] \ No newline at end of file From 1500c83cce68b9dd0214bfcaa22c812c3ef27ffd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Oct 2013 11:42:50 +0530 Subject: [PATCH 02/10] -am --- patches/october_2013/p04_update_report_permission.py | 9 +++++++++ patches/patch_list.py | 1 + 2 files changed, 10 insertions(+) create mode 100644 patches/october_2013/p04_update_report_permission.py diff --git a/patches/october_2013/p04_update_report_permission.py b/patches/october_2013/p04_update_report_permission.py new file mode 100644 index 0000000000..1a9f99d533 --- /dev/null +++ b/patches/october_2013/p04_update_report_permission.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +import webnotes + +def execute(): + webnotes.conn.sql("""update tabDocPerm set `create`=1 where + parent='Report' + and role in ('Administrator', 'Report Manager', 'System Manager')""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index e353ab628a..11bb8dc7fd 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -225,4 +225,5 @@ patch_list = [ "patches.october_2013.p02_update_price_list_and_item_details_in_item_price", "execute:webnotes.delete_doc('Report', 'Item-wise Price List')", "patches.october_2013.p03_remove_sales_and_purchase_return_tool", + "patches.october_2013.p04_update_report_permission", ] \ No newline at end of file From 49f9e284ffdac2f48ab152221ebba1ac6926968d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Oct 2013 12:11:20 +0530 Subject: [PATCH 03/10] [report] lead details --- selling/page/selling_home/selling_home.js | 5 +++++ selling/report/lead_details/__init__.py | 0 selling/report/lead_details/lead_details.txt | 22 ++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 selling/report/lead_details/__init__.py create mode 100644 selling/report/lead_details/lead_details.txt diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index a69e50b06b..4981ee77f5 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -167,6 +167,11 @@ wn.module_page["Selling"] = [ right: true, icon: "icon-list", items: [ + { + "label":wn._("Lead Details"), + route: "query-report/Lead Details", + doctype: "Lead" + }, { "label":wn._("Customer Addresses And Contacts"), route: "query-report/Customer Addresses And Contacts", diff --git a/selling/report/lead_details/__init__.py b/selling/report/lead_details/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/report/lead_details/lead_details.txt b/selling/report/lead_details/lead_details.txt new file mode 100644 index 0000000000..6da9b79c49 --- /dev/null +++ b/selling/report/lead_details/lead_details.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-10-22 11:58:16", + "docstatus": 0, + "modified": "2013-10-22 12:08:18", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "SELECT\n `tabLead`.name as \"Lead Id:Link/Lead:120\",\n `tabLead`.lead_name as \"Lead Name::120\",\n\t`tabLead`.company_name as \"Company Name::120\",\n\t`tabLead`.status as \"Status::120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n\t`tabLead`.phone as \"Phone::100\",\n\t`tabLead`.mobile_no as \"Mobile No::100\",\n\t`tabLead`.email_id as \"Email Id::120\",\n\t`tabLead`.lead_owner as \"Lead Owner::120\",\n\t`tabLead`.source as \"Source::120\",\n\t`tabLead`.territory as \"Territory::120\"\nFROM\n\t`tabLead`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.lead=`tabLead`.name\n\t)\nWHERE\n\t`tabLead`.docstatus<2\nORDER BY\n\t`tabLead`.name asc", + "ref_doctype": "Lead", + "report_name": "Lead Details", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Lead Details" + } +] \ No newline at end of file From cf8ae7c3d970ccf80e88f70fe35a440c8a31841a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Oct 2013 12:57:19 +0530 Subject: [PATCH 04/10] [fix] [minor] perpetual inventory related --- controllers/stock_controller.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py index d4c92a90a7..54b6d9f983 100644 --- a/controllers/stock_controller.py +++ b/controllers/stock_controller.py @@ -91,9 +91,6 @@ class StockController(AccountsController): return stock_ledger def get_warehouse_account(self): - for d in webnotes.conn.sql("select name from tabWarehouse"): - webnotes.bean("Warehouse", d[0]).save() - warehouse_account = dict(webnotes.conn.sql("""select master_name, name from tabAccount where account_type = 'Warehouse' and ifnull(master_name, '') != ''""")) return warehouse_account From 145e5e26fa0e0f4dbff051b42eaddc33ef9e2255 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Oct 2013 23:51:41 +0530 Subject: [PATCH 05/10] [patch] delete gl entries for cancelled vouchers --- controllers/stock_controller.py | 20 +++++++++---------- ...elete_gl_entries_for_cancelled_vouchers.py | 17 ++++++++++++++++ patches/patch_list.py | 1 + 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py index 54b6d9f983..359dc9e86f 100644 --- a/controllers/stock_controller.py +++ b/controllers/stock_controller.py @@ -12,18 +12,17 @@ from accounts.general_ledger import make_gl_entries, delete_gl_entries class StockController(AccountsController): def make_gl_entries(self): - if not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")): - return - - warehouse_account = self.get_warehouse_account() - - if self.doc.docstatus==1: - gl_entries = self.get_gl_entries_for_stock(warehouse_account) - make_gl_entries(gl_entries) - else: + 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")): + warehouse_account = self.get_warehouse_account() - self.update_gl_entries_after(warehouse_account) + if self.doc.docstatus==1: + gl_entries = self.get_gl_entries_for_stock(warehouse_account) + make_gl_entries(gl_entries) + + self.update_gl_entries_after(warehouse_account) def get_gl_entries_for_stock(self, warehouse_account=None, default_expense_account=None, default_cost_center=None): @@ -96,7 +95,6 @@ class StockController(AccountsController): return warehouse_account def update_gl_entries_after(self, warehouse_account=None): - from accounts.utils import get_stock_and_account_difference future_stock_vouchers = self.get_future_stock_vouchers() gle = self.get_voucherwise_gl_entries(future_stock_vouchers) if not warehouse_account: diff --git a/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py b/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py new file mode 100644 index 0000000000..ebe7a695f3 --- /dev/null +++ b/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py @@ -0,0 +1,17 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +def execute(): + import webnotes + entries = webnotes.conn.sql("""select voucher_type, voucher_no + from `tabGL Entry` group by voucher_type, voucher_no""", as_dict=1) + for entry in entries: + try: + cancelled_voucher = webnotes.conn.sql("""select name from `tab%s` where name = %s + and docstatus=2""" % (entry['voucher_type'], "%s"), entry['voucher_no']) + if cancelled_voucher: + print entry + webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type = %s and + voucher_no = %s""", (entry['voucher_type'], entry['voucher_no'])) + except: + pass \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 11bb8dc7fd..565ff9915f 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -226,4 +226,5 @@ patch_list = [ "execute:webnotes.delete_doc('Report', 'Item-wise Price List')", "patches.october_2013.p03_remove_sales_and_purchase_return_tool", "patches.october_2013.p04_update_report_permission", + "patches.october_2013.p05_delete_gl_entries_for_cancelled_vouchers", ] \ No newline at end of file From decf51de4a4c2761151cd4e060b36846bdb07d75 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Oct 2013 23:55:34 +0530 Subject: [PATCH 06/10] [patch] delete gl entries for cancelled vouchers --- patches/october_2012/fix_cancelled_gl_entries.py | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/october_2012/fix_cancelled_gl_entries.py b/patches/october_2012/fix_cancelled_gl_entries.py index b610985dcd..475ea1c053 100644 --- a/patches/october_2012/fix_cancelled_gl_entries.py +++ b/patches/october_2012/fix_cancelled_gl_entries.py @@ -11,6 +11,7 @@ def execute(): and docstatus=2""" % (entry['voucher_type'], "%s"), entry['voucher_no']) is_cancelled = docstatus and 'Yes' or None if is_cancelled: + print entry['voucher_type'], entry['voucher_no'] webnotes.conn.sql("""update `tabGL Entry` set is_cancelled = 'Yes' where voucher_type = %s and voucher_no = %s""", (entry['voucher_type'], entry['voucher_no'])) From 688c2ef588ea14d26b3d2c34aecaca7d1d578898 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 23 Oct 2013 00:26:53 +0530 Subject: [PATCH 07/10] [patch] delete gl entries for cancelled vouchers --- .../october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py b/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py index ebe7a695f3..1d8657abb3 100644 --- a/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py +++ b/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py @@ -10,7 +10,6 @@ def execute(): cancelled_voucher = webnotes.conn.sql("""select name from `tab%s` where name = %s and docstatus=2""" % (entry['voucher_type'], "%s"), entry['voucher_no']) if cancelled_voucher: - print entry webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type = %s and voucher_no = %s""", (entry['voucher_type'], entry['voucher_no'])) except: From 4ed7f6834452f97b0f15c83ee0ac346217a7208e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 23 Oct 2013 11:50:09 +0530 Subject: [PATCH 08/10] [utility] repost stock --- setup/doctype/global_defaults/global_defaults.txt | 9 +-------- utilities/repost_stock.py | 7 +++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index fbfa8ca14d..a8a80b1045 100644 --- a/setup/doctype/global_defaults/global_defaults.txt +++ b/setup/doctype/global_defaults/global_defaults.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-02 17:53:24", "docstatus": 0, - "modified": "2013-08-06 11:22:22", + "modified": "2013-10-23 10:22:44", "modified_by": "Administrator", "owner": "Administrator" }, @@ -175,13 +175,6 @@ "options": "Standard\nClassic\nModern\nSpartan", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "hr", - "fieldtype": "Section Break", - "label": "HR", - "read_only": 0 - }, { "doctype": "DocPerm" } diff --git a/utilities/repost_stock.py b/utilities/repost_stock.py index 735930486e..e2ecdeeb9b 100644 --- a/utilities/repost_stock.py +++ b/utilities/repost_stock.py @@ -13,8 +13,11 @@ def repost(): """ webnotes.conn.auto_commit_on_many_writes = 1 - for d in webnotes.conn.sql("select item_code, warehouse from tabBin"): - repost_stock(d[0], d[1]) + for d in webnotes.conn.sql("""select distinct item_code, warehouse from + (select item_code, warehouse from tabBin + union + select item_code, warehouse from `tabStock Ledger Entry`)"""): + repost_stock(d[0], d[1]) webnotes.conn.auto_commit_on_many_writes = 0 From c2caae53dd93219b7cafb2a75dbf9b37b2f508e2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 23 Oct 2013 12:02:08 +0530 Subject: [PATCH 09/10] [utility] repost stock --- utilities/repost_stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/repost_stock.py b/utilities/repost_stock.py index e2ecdeeb9b..136a7620b5 100644 --- a/utilities/repost_stock.py +++ b/utilities/repost_stock.py @@ -16,7 +16,7 @@ def repost(): for d in webnotes.conn.sql("""select distinct item_code, warehouse from (select item_code, warehouse from tabBin union - select item_code, warehouse from `tabStock Ledger Entry`)"""): + select item_code, warehouse from `tabStock Ledger Entry`) a"""): repost_stock(d[0], d[1]) webnotes.conn.auto_commit_on_many_writes = 0 From 5048c98911b430af899a423a73f74214674235b7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 23 Oct 2013 12:14:32 +0530 Subject: [PATCH 10/10] [utility] repost stock --- utilities/repost_stock.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utilities/repost_stock.py b/utilities/repost_stock.py index 136a7620b5..536df81e8b 100644 --- a/utilities/repost_stock.py +++ b/utilities/repost_stock.py @@ -34,7 +34,10 @@ def repost_stock(item_code, warehouse): def repost_actual_qty(item_code, warehouse): from stock.stock_ledger import update_entries_after - update_entries_after({ "item_code": item_code, "warehouse": warehouse }) + try: + update_entries_after({ "item_code": item_code, "warehouse": warehouse }) + except: + pass def get_reserved_qty(item_code, warehouse): reserved_qty = webnotes.conn.sql("""