From 104294134828fade8fce96ea27b620e020218a78 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Thu, 8 Jun 2017 18:45:50 +0530 Subject: [PATCH] [hotfix] fixes for mysql Lock wait timeout exceeded --- erpnext/stock/doctype/bin/bin.json | 38 ++++++++++++++++++++++++++---- erpnext/stock/doctype/bin/bin.py | 8 ++++++- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/doctype/bin/bin.json b/erpnext/stock/doctype/bin/bin.json index 0481cfc002..e33e54db9c 100644 --- a/erpnext/stock/doctype/bin/bin.json +++ b/erpnext/stock/doctype/bin/bin.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, "autoname": "BIN/.#######", @@ -12,6 +13,7 @@ "engine": "InnoDB", "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -22,6 +24,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 1, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 1, "label": "Warehouse", @@ -42,6 +45,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -52,6 +56,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 1, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 1, "label": "Item Code", @@ -72,6 +77,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -83,6 +89,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Reserved Quantity", @@ -102,6 +109,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -113,6 +121,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 1, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Actual Quantity", @@ -132,6 +141,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -143,6 +153,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Ordered Quantity", @@ -162,6 +173,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -173,6 +185,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Requested Quantity", @@ -192,6 +205,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -202,6 +216,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Planned Qty", @@ -221,6 +236,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -231,6 +247,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Projected Qty", @@ -250,6 +267,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -260,6 +278,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Reserved Qty for Production", @@ -278,6 +297,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -288,6 +308,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Moving Average Rate", @@ -307,6 +328,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -317,6 +339,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 1, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "UOM", @@ -337,6 +360,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -347,6 +371,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "FCFS Rate", @@ -366,6 +391,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -376,6 +402,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Valuation Rate", @@ -395,6 +422,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -405,6 +433,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Stock Value", @@ -424,17 +453,17 @@ "unique": 0 } ], + "has_web_view": 0, "hide_heading": 0, "hide_toolbar": 1, "idx": 1, "image_view": 0, "in_create": 1, - "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-12-15 14:51:43.312590", + "modified": "2017-06-08 18:42:44.714839", "modified_by": "Administrator", "module": "Stock", "name": "Bin", @@ -450,7 +479,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -471,7 +499,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -492,7 +519,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -508,6 +534,8 @@ "read_only": 0, "read_only_onload": 0, "search_fields": "item_code,warehouse", + "show_name_in_global_search": 0, "sort_order": "ASC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index ece8220812..6e693307dd 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -31,6 +31,7 @@ class Bin(Document): is_group_warehouse(self.warehouse) def update_stock(self, args, allow_negative_stock=False, via_landed_cost_voucher=False): + '''Called from erpnext.stock.utils.update_bin''' self.update_qty(args) if args.get("actual_qty") or args.get("voucher_type") == "Stock Reconciliation": @@ -71,8 +72,10 @@ class Bin(Document): self.reserved_qty = flt(self.reserved_qty) + flt(args.get("reserved_qty")) self.indented_qty = flt(self.indented_qty) + flt(args.get("indented_qty")) self.planned_qty = flt(self.planned_qty) + flt(args.get("planned_qty")) + + self.set_projected_qty() - self.save() + self.db_save() def set_projected_qty(self): self.projected_qty = (flt(self.actual_qty) + flt(self.ordered_qty) @@ -111,3 +114,6 @@ def update_item_projected_qty(item_code): frappe.db.sql('''update tabItem set total_projected_qty = ifnull((select sum(projected_qty) from tabBin where item_code=%s), 0) where name=%s''', (item_code, item_code)) + +def on_doctype_update(): + frappe.db.add_index("Bin", ["item_code", "warehouse"])