From 3d549775e134e5888d02275ea4be65fe5fee501a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 3 Aug 2012 14:19:05 +0530 Subject: [PATCH 1/6] mark 'Supplier Quotation' as a beta feature --- erpnext/buying/page/buying_home/buying_home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/page/buying_home/buying_home.html b/erpnext/buying/page/buying_home/buying_home.html index cd9312c7f1..c2eead1100 100644 --- a/erpnext/buying/page/buying_home/buying_home.html +++ b/erpnext/buying/page/buying_home/buying_home.html @@ -5,7 +5,7 @@

Purchase Request

Request for purchase


-

Supplier Quotation

+

Supplier Quotation (beta)

Track Quotations received from Suppliers


Purchase Order

From 786444e6bf756535606927fd3552f82d1abf1a3f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 3 Aug 2012 16:15:39 +0530 Subject: [PATCH 2/6] changed document_type of 'Communication' to 'Master' to enable importing --- .../doctype/communication/communication.txt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/erpnext/support/doctype/communication/communication.txt b/erpnext/support/doctype/communication/communication.txt index bb69e6e038..d504476b36 100644 --- a/erpnext/support/doctype/communication/communication.txt +++ b/erpnext/support/doctype/communication/communication.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-06-07 11:02:55', + 'creation': '2012-06-26 11:58:13', 'docstatus': 0, - 'modified': '2012-06-07 11:24:20', + 'modified': '2012-08-03 16:10:35', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -15,6 +15,7 @@ 'allow_attach': 1, 'description': u'Keep a track of all communications', 'doctype': 'DocType', + 'document_type': u'Master', 'module': u'Support', 'name': '__common__', 'version': 1 @@ -86,7 +87,7 @@ # DocPerm { - 'cancel': 0, + 'cancel': 1, 'create': 0, 'doctype': u'DocPerm', 'permlevel': 1, @@ -99,16 +100,7 @@ 'create': 1, 'doctype': u'DocPerm', 'permlevel': 0, - 'role': u'Administrator' - }, - - # DocPerm - { - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Administrator' + 'role': u'Support Manager' }, # DocField From df902d1a0c359f21aff927f193ba403ac22f47cd Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 3 Aug 2012 19:11:11 +0530 Subject: [PATCH 3/6] patch: repost stock due to wrong packing list entries - optimized query using index and subqueries --- .../repost_stock_due_to_wrong_packing_list.py | 59 ++++++++++++------- erpnext/patches/patch_list.py | 4 ++ 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py index 5900a0af56..659bcc0408 100644 --- a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py +++ b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py @@ -1,23 +1,45 @@ +import webnotes + +def execute(): + # add index + webnotes.conn.commit() + webnotes.conn.sql("""drop index item_code_warehouse on `tabDelivery Note Packing Item`""") + webnotes.conn.sql("""create index item_code_warehouse + on `tabDelivery Note Packing Item` (item_code, warehouse)""") + webnotes.conn.begin() + + repost_reserved_qty() + cleanup_wrong_sle() + def repost_reserved_qty(): - import webnotes from webnotes.utils import flt bins = webnotes.conn.sql("select item_code, warehouse, name, reserved_qty from `tabBin`") + i = 0 for d in bins: + i += 1 + print i reserved_qty = webnotes.conn.sql(""" - select sum((dnpi.qty/so_item.qty)*(so_item.qty - ifnull(so_item.delivered_qty, 0))) - - from `tabDelivery Note Packing Item` dnpi, `tabSales Order Item` so_item, `tabSales Order` so - - where dnpi.item_code = %s - and dnpi.warehouse = %s - and dnpi.parent = so.name - and so_item.parent = so.name - and dnpi.parenttype = 'Sales Order' - and dnpi.parent_detail_docname = so_item.name - and dnpi.parent_item = so_item.item_code - and so.docstatus = 1 - and so.status != 'Stopped' - """, (d[0], d[1])) + select sum((dnpi_qty / so_item_qty) * (so_item_qty - so_item_delivered_qty)) + from (select + qty as dnpi_qty, + ( + select qty from `tabSales Order Item` + where name = dnpi.parent_detail_docname + ) as so_item_qty, + ( + select ifnull(delivered_qty, 0) from `tabSales Order Item` + where name = dnpi.parent_detail_docname + ) as so_item_delivered_qty + from + ( + select qty, parent_detail_docname + from `tabDelivery Note Packing Item` dnpi_in + where item_code = %s and warehouse = %s + and parenttype="Sales Order" + and exists (select * from `tabSales Order` so + where name = dnpi_in.parent and docstatus = 1 and status != 'Stopped') + ) dnpi) tab""", (d[0], d[1])) + if flt(d[3]) != flt(reserved_qty[0][0]): print d[3], reserved_qty[0][0] webnotes.conn.sql(""" @@ -67,9 +89,4 @@ def repost_bin(item, wh): bin = webnotes.conn.sql("select name from `tabBin` \ where item_code = %s and warehouse = %s", (item, wh)) - get_obj('Bin', bin[0][0]).update_entries_after(posting_date = '2012-07-01', posting_time = '12:05') - - -def execute(): - repost_reserved_qty() - cleanup_wrong_sle() + get_obj('Bin', bin[0][0]).update_entries_after(posting_date = '2012-07-01', posting_time = '12:05') \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index e74206ab94..eace14c368 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -509,4 +509,8 @@ patch_list = [ 'patch_module': 'patches.july_2012', 'patch_file': 'project_patch_repeat', }, + { + 'patch_module': 'patches.july_2012', + 'patch_file': 'repost_stock_due_to_wrong_packing_list', + }, ] \ No newline at end of file From fea3b64dd0d58524eb30a76c950f2b0caaa02745 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 3 Aug 2012 19:14:42 +0530 Subject: [PATCH 4/6] fixed patch: repost stock due to wrong packing list --- .../patches/july_2012/repost_stock_due_to_wrong_packing_list.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py index 659bcc0408..a8077c224d 100644 --- a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py +++ b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py @@ -3,7 +3,6 @@ import webnotes def execute(): # add index webnotes.conn.commit() - webnotes.conn.sql("""drop index item_code_warehouse on `tabDelivery Note Packing Item`""") webnotes.conn.sql("""create index item_code_warehouse on `tabDelivery Note Packing Item` (item_code, warehouse)""") webnotes.conn.begin() From 326f88cce660bdd10da0b26685631536eb6d2e21 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 3 Aug 2012 19:19:23 +0530 Subject: [PATCH 5/6] fixed patch: repost stock due to wrong packing list --- .../repost_stock_due_to_wrong_packing_list.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py index a8077c224d..3b21ca6102 100644 --- a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py +++ b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py @@ -3,8 +3,11 @@ import webnotes def execute(): # add index webnotes.conn.commit() - webnotes.conn.sql("""create index item_code_warehouse - on `tabDelivery Note Packing Item` (item_code, warehouse)""") + try: + webnotes.conn.sql("""create index item_code_warehouse + on `tabDelivery Note Packing Item` (item_code, warehouse)""") + except: + pass webnotes.conn.begin() repost_reserved_qty() @@ -72,9 +75,6 @@ def cleanup_wrong_sle(): def create_comment(dn): from webnotes.model.doc import Document cmt = Document('Comment') - for arg in ['comment', 'comment_by', 'comment_by_fullname', 'comment_doctype', \ - 'comment_docname']: - cmt.fields[arg] = args[arg] cmt.comment = 'Cancelled by administrator due to wrong entry in packing list' cmt.comment_by = 'Administrator' cmt.comment_by_fullname = 'Administrator' From fd03762445402f6cf79139d5f06929903e02bc9d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 Aug 2012 13:18:32 +0530 Subject: [PATCH 6/6] call item on_update from UOM Replace Utility --- erpnext/stock/doctype/item/item.py | 2 +- .../stock_uom_replace_utility.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 9e00dc12bf..c21b552232 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -66,7 +66,7 @@ class DocType: if cstr(d.uom) == cstr(self.doc.stock_uom): if flt(d.conversion_factor) != 1: - msgprint("Conversion Fator of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name))) + msgprint("Conversion Factor of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name))) raise Exception # else set uom_exist as true uom_exist='true' diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py index 8414f8afbe..31188e876e 100644 --- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py +++ b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py @@ -44,10 +44,6 @@ class DocType: if not cstr(self.doc.item_code): msgprint("Please Enter an Item.") raise Exception - - if not cstr(self.doc.current_stock_uom): - msgprint("There is no Current Stock UOM for Item Code" + cstr(self.doc.item_code)) - raise Exception if not cstr(self.doc.new_stock_uom): msgprint("Please Enter New Stock UOM.") @@ -118,4 +114,6 @@ class DocType: self.update_stock_ledger_entry() # update bin - self.update_bin() \ No newline at end of file + self.update_bin() + + get_obj("Item", self.doc.item_code).on_update() \ No newline at end of file