From 9665fd967e2f47904bc352526a79f3a1ec52c240 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 2 Feb 2013 19:20:35 +0530 Subject: [PATCH 1/7] fixes in alter table and updated listviews for delivery note and purchase receipt --- stock/doctype/delivery_note/delivery_note.txt | 10 ++++++---- stock/doctype/purchase_receipt/purchase_receipt.txt | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt index 5fe85921ba..618d172d07 100644 --- a/stock/doctype/delivery_note/delivery_note.txt +++ b/stock/doctype/delivery_note/delivery_note.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-23 19:57:19", + "creation": "2013-01-29 17:54:12", "docstatus": 0, - "modified": "2013-01-29 16:28:03", + "modified": "2013-02-02 19:18:38", "modified_by": "Administrator", "owner": "Administrator" }, @@ -862,8 +862,9 @@ "description": "% of materials billed against this Delivery Note", "doctype": "DocField", "fieldname": "per_billed", - "fieldtype": "Float", + "fieldtype": "Percent", "in_filter": 1, + "in_list_view": 1, "label": "% Amount Billed", "no_copy": 1, "oldfieldname": "per_billed", @@ -888,8 +889,9 @@ "description": "% of materials delivered against this Delivery Note", "doctype": "DocField", "fieldname": "per_installed", - "fieldtype": "Float", + "fieldtype": "Percent", "in_filter": 1, + "in_list_view": 1, "label": "% Installed", "no_copy": 1, "oldfieldname": "per_installed", diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt index 0c7a4c30a1..3ecbb03947 100755 --- a/stock/doctype/purchase_receipt/purchase_receipt.txt +++ b/stock/doctype/purchase_receipt/purchase_receipt.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-22 15:24:18", "docstatus": 0, - "modified": "2013-01-29 16:28:01", + "modified": "2013-02-02 19:09:37", "modified_by": "Administrator", "owner": "Administrator" }, @@ -627,7 +627,8 @@ "description": "% of materials billed against this Purchase Receipt", "doctype": "DocField", "fieldname": "per_billed", - "fieldtype": "Float", + "fieldtype": "Percent", + "in_list_view": 1, "label": "% Billed", "no_copy": 1, "oldfieldname": "per_billed", From 1af093f6b03a84b6271159e6aeaa6c31e98dbd0f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 2 Feb 2013 22:33:26 +0530 Subject: [PATCH 2/7] fixes in purchase invoice gl entry --- accounts/doctype/purchase_invoice/purchase_invoice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 9ce939c79f..5f7e848a53 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -436,13 +436,15 @@ class DocType(BuyingController): # tax table gl entries for tax in getlist(self.doclist, "purchase_tax_details"): if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount): - valuation_tax += flt(tax.tax_amount) + valuation_tax += tax.add_deduct_tax == "Add" \ + and flt(tax.tax_amount) or -1 * flt(tax.tax_amount) gl_entries.append( self.get_gl_dict({ "account": tax.account_head, "against": self.doc.credit_to, - "debit": tax.tax_amount, + "debit": tax.add_deduct_tax == "Add" and tax.tax_amount or 0, + "credit": tax.add_deduct_tax == "Deduct" and tax.tax_amount or 0, "remarks": self.doc.remarks, "cost_center": tax.cost_center }, is_cancel) From 4f8dfd69f96d756f8e140ca2413668a9ed65a4d4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sun, 3 Feb 2013 22:42:05 +0530 Subject: [PATCH 3/7] messages.py use begin/commit for messages --- utilities/page/messages/messages.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utilities/page/messages/messages.py b/utilities/page/messages/messages.py index bec0e32520..7fbc10121f 100644 --- a/utilities/page/messages/messages.py +++ b/utilities/page/messages/messages.py @@ -25,10 +25,12 @@ def get_list(arg=None): webnotes.form_dict['user'] = webnotes.session['user'] # set all messages as read + webnotes.conn.begin() webnotes.conn.sql("""UPDATE `tabComment` set docstatus = 1 where comment_doctype in ('My Company', 'Message') and comment_docname = %s """, webnotes.user.name) + webnotes.conn.commit() if webnotes.form_dict['contact'] == webnotes.session['user']: # return messages From d39c55ae4b3ed06497cae424e44a3f7e8cf2166f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 4 Feb 2013 10:24:43 +0530 Subject: [PATCH 4/7] added explain to get_status in field for debugging --- buying/doctype/purchase_request_item/purchase_request_item.txt | 3 ++- hr/doctype/expense_claim/expense_claim.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/buying/doctype/purchase_request_item/purchase_request_item.txt b/buying/doctype/purchase_request_item/purchase_request_item.txt index 403c7a2cce..f364ddb152 100644 --- a/buying/doctype/purchase_request_item/purchase_request_item.txt +++ b/buying/doctype/purchase_request_item/purchase_request_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:11", "docstatus": 0, - "modified": "2013-01-22 14:47:56", + "modified": "2013-02-04 09:52:22", "modified_by": "Administrator", "owner": "Administrator" }, @@ -26,6 +26,7 @@ "name": "Purchase Request Item" }, { + "allow_on_submit": 0, "doctype": "DocField", "fieldname": "schedule_date", "fieldtype": "Date", diff --git a/hr/doctype/expense_claim/expense_claim.txt b/hr/doctype/expense_claim/expense_claim.txt index 954a694702..0ceb21486b 100644 --- a/hr/doctype/expense_claim/expense_claim.txt +++ b/hr/doctype/expense_claim/expense_claim.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:14", "docstatus": 0, - "modified": "2013-01-29 17:43:18", + "modified": "2013-02-04 09:22:51", "modified_by": "Administrator", "owner": "harshada@webnotestech.com" }, From 87462b68a7a29ce7aa2ebb0916b7cd3b3ef18146 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 4 Feb 2013 10:30:43 +0530 Subject: [PATCH 5/7] actual_date in maintenance schedule not read_only --- .../maintenance_schedule_detail.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt b/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt index 41b83be986..ba30be43dd 100644 --- a/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt +++ b/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:31", "docstatus": 0, - "modified": "2013-01-22 14:47:02", + "modified": "2013-02-04 10:30:18", "modified_by": "Administrator", "owner": "Administrator" }, @@ -70,7 +70,7 @@ "oldfieldname": "actual_date", "oldfieldtype": "Date", "print_hide": 1, - "read_only": 1, + "read_only": 0, "report_hide": 1 }, { From 0dbe898d82260f25c756f528522a0124d10672b7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 4 Feb 2013 13:56:50 +0530 Subject: [PATCH 6/7] added warehouse user to retrict entry and also introduced query handlers --- home/page/latest_updates/latest_updates.js | 3 ++ startup/query_handlers.py | 5 +++ .../stock_ledger_entry/stock_ledger_entry.py | 11 ++++++ stock/doctype/warehouse/warehouse.txt | 17 ++++++++- stock/doctype/warehouse_user/__init__.py | 0 .../doctype/warehouse_user/warehouse_user.py | 8 +++++ .../doctype/warehouse_user/warehouse_user.txt | 36 +++++++++++++++++++ stock/utils.py | 19 +++++++++- 8 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 startup/query_handlers.py create mode 100644 stock/doctype/warehouse_user/__init__.py create mode 100644 stock/doctype/warehouse_user/warehouse_user.py create mode 100644 stock/doctype/warehouse_user/warehouse_user.txt diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index d1561e05bf..db64849e72 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,7 @@ erpnext.updates = [ + ["2nd February, 2013", [ + "Warehouse: Added table Warehouse User to restrict Warehouse Entry per user.", + ]], ["28st January, 2013", [ "List Views are now configurable: To set list views, check 'In List View' in Setup > Customize Form View in the fields table.", ]], diff --git a/startup/query_handlers.py b/startup/query_handlers.py new file mode 100644 index 0000000000..5e2860865f --- /dev/null +++ b/startup/query_handlers.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +standard_queries = { + "Warehouse": "stock.utils.get_warehouse_list" +} \ No newline at end of file diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 2b1af33e50..d1fe3d95b2 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -16,6 +16,7 @@ from __future__ import unicode_literals import webnotes +from webnotes import _ from webnotes.utils import cint, flt, getdate @@ -33,6 +34,7 @@ class DocType: def validate(self): self.validate_mandatory() self.validate_item() + self.validate_warehouse_user() self.actual_amt_check() self.check_stock_frozen_date() self.scrub_posting_time() @@ -51,6 +53,15 @@ class DocType: self.doc.fields.pop('batch_bal') + def validate_warehouse_user(self): + if webnotes.session.user=="Administrator": + return + warehouse_users = [p[0] for p in webnotes.conn.sql("""select user from `tabWarehouse User` + where parent=%s""", self.doc.warehouse)] + + if warehouse_users and not webnotes.session.user in warehouse_users: + webnotes.msgprint(_("User not allowed entry in the Warehouse") \ + + ": " + webnotes.session.user + " / " + self.doc.warehouse, raise_exception = 1) def validate_mandatory(self): mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company'] diff --git a/stock/doctype/warehouse/warehouse.txt b/stock/doctype/warehouse/warehouse.txt index e76754382c..d0dd73c086 100644 --- a/stock/doctype/warehouse/warehouse.txt +++ b/stock/doctype/warehouse/warehouse.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:30", "docstatus": 0, - "modified": "2013-01-29 13:29:21", + "modified": "2013-02-04 11:35:53", "modified_by": "Administrator", "owner": "Administrator" }, @@ -80,6 +80,21 @@ "permlevel": 0, "search_index": 1 }, + { + "doctype": "DocField", + "fieldname": "column_break_4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "If set, data entry is only allowed for specified users. Else, entry is allowed for all users with requisite permissions.", + "doctype": "DocField", + "fieldname": "warehouse_users", + "fieldtype": "Table", + "label": "Warehouse Users", + "options": "Warehouse User", + "permlevel": 0 + }, { "description": "For Reference Only.", "doctype": "DocField", diff --git a/stock/doctype/warehouse_user/__init__.py b/stock/doctype/warehouse_user/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/doctype/warehouse_user/warehouse_user.py b/stock/doctype/warehouse_user/warehouse_user.py new file mode 100644 index 0000000000..928aa9ff9f --- /dev/null +++ b/stock/doctype/warehouse_user/warehouse_user.py @@ -0,0 +1,8 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/stock/doctype/warehouse_user/warehouse_user.txt b/stock/doctype/warehouse_user/warehouse_user.txt new file mode 100644 index 0000000000..6cb02ae7fd --- /dev/null +++ b/stock/doctype/warehouse_user/warehouse_user.txt @@ -0,0 +1,36 @@ +[ + { + "creation": "2013-02-04 11:33:57", + "docstatus": 0, + "modified": "2013-02-04 11:36:16", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "DocType", + "document_type": "Other", + "istable": 1, + "module": "Stock", + "name": "__common__" + }, + { + "doctype": "DocField", + "fieldname": "user", + "fieldtype": "Link", + "label": "User", + "name": "__common__", + "options": "Profile", + "parent": "Warehouse User", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0, + "width": "200px" + }, + { + "doctype": "DocType", + "name": "Warehouse User" + }, + { + "doctype": "DocField" + } +] \ No newline at end of file diff --git a/stock/utils.py b/stock/utils.py index 46dd9d01a9..87f4c02ad1 100644 --- a/stock/utils.py +++ b/stock/utils.py @@ -146,4 +146,21 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''): + cstr(abs(qty)) + " quantity against item code: " + item_code, raise_exception=1) - return valid_serial_nos \ No newline at end of file + return valid_serial_nos + +def get_warehouse_list(doctype, txt, searchfield, start, page_len): + """used in search queries""" + wlist = [] + for w in webnotes.conn.sql_list("""select name from tabWarehouse + where name like '%%%s%%'""" % txt): + if webnotes.session.user=="Administrator": + wlist.append([w]) + else: + warehouse_users = webnotes.conn.sql_list("""select user from `tabWarehouse User` + where parent=%s""", w) + if not warehouse_users: + wlist.append([w]) + elif webnotes.session.user in warehouse_users: + wlist.append([w]) + return wlist + \ No newline at end of file From cb5a05ea98982721e93b5d457ff50f87e4cb2c3a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 4 Feb 2013 13:57:54 +0530 Subject: [PATCH 7/7] fixes in stock ledger report --- stock/page/stock_ledger/stock_ledger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js index b999dd0494..82230e4cef 100644 --- a/stock/page/stock_ledger/stock_ledger.js +++ b/stock/page/stock_ledger/stock_ledger.js @@ -208,7 +208,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({ } } - if(me.item_code != me.item_code_default && !me.voucher_no) { + if(me.item_code && !me.voucher_no) { var closing = { item_code: "On " + dateutil.str_to_user(this.to_date), balance: (out.length ? out[out.length-1].balance : 0), qty: 0,