diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py index d4c92a90a7..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): @@ -91,15 +90,11 @@ 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 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/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_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'])) 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/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/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..1d8657abb3 --- /dev/null +++ b/patches/october_2013/p05_delete_gl_entries_for_cancelled_vouchers.py @@ -0,0 +1,16 @@ +# 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: + 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 0b27a2e0d8..565ff9915f 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -224,4 +224,7 @@ 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", + "patches.october_2013.p04_update_report_permission", + "patches.october_2013.p05_delete_gl_entries_for_cancelled_vouchers", ] \ No newline at end of file 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 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..536df81e8b 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`) a"""): + repost_stock(d[0], d[1]) webnotes.conn.auto_commit_on_many_writes = 0 @@ -31,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("""