From 9437f39c86aede8e70c5f8ac7dc86e6059f7d3f2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 14 Jan 2013 15:52:22 +0530 Subject: [PATCH] fixes in stock reco --- .../stock_reconciliation/stock_reconciliation.py | 12 +++++++++--- stock/doctype/warehouse/warehouse.py | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py index 3a8ffcde07..8afe1d2f7d 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -36,6 +36,9 @@ class DocType(DocListController): self.delete_stock_ledger_entries() def validate_data(self): + if not self.doc.reconciliation_json: + return + data = json.loads(self.doc.reconciliation_json) if self.head_row not in data: msgprint(_("""Hey! You seem to be using the wrong template. \ @@ -118,6 +121,9 @@ class DocType(DocListController): row_template = ["item_code", "warehouse", "qty", "valuation_rate"] + if not self.doc.reconciliation_json: + msgprint(_("""Stock Reconciliation file not uploaded"""), raise_exception=1) + data = json.loads(self.doc.reconciliation_json) for row_num, row in enumerate(data[data.index(self.head_row)+1:]): row = webnotes._dict(zip(row_template, row)) @@ -229,13 +235,13 @@ class DocType(DocListController): args.update(opts) # create stock ledger entry - sle_wrapper = webnotes.model_wrapper([args]).insert() + sle_wrapper = webnotes.model_wrapper([args]) + sle_wrapper.ignore_permissions = 1 + sle_wrapper.insert() # update bin webnotes.get_obj('Warehouse', row.warehouse).update_bin(args) - # update_entries_after(args) - return sle_wrapper def delete_stock_ledger_entries(self): diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 8d6065c5f8..7c3cbd6feb 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -39,7 +39,9 @@ class DocType: "doctype": "Bin", "item_code": item_code, "warehouse": warehouse, - }]).insert() + }]) + bin_wrapper.ignore_permissions = 1 + bin_wrapper.insert() bin_obj = bin_wrapper.make_obj() else: