From 9f1b59dfc615cc4b2e240344b182cc5601d0cc66 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 20:34:09 +0530 Subject: [PATCH 1/7] Fixes in sales return validation --- stock/doctype/stock_entry/stock_entry.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index ba0e72478c..2e7e2a4066 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -287,9 +287,15 @@ class DocType(StockController): # validate quantity <= ref item's qty - qty already returned ref_item = ref.doclist.getone({"item_code": item.item_code}) returnable_qty = ref_item.qty - flt(already_returned_item_qty.get(item.item_code)) - self.validate_value("transfer_qty", "<=", returnable_qty, item, - raise_exception=StockOverReturnError) - + if not returnable_qty: + webnotes.throw("{item}: {item_code} {returned}".format( + item=_("Item"), item_code=item.item_code, + returned=_("already returned though some other documents"))) + elif item.transfer_qty > returnable_qty: + webnotes.throw("{item}: {item_code}, {returned}: {qty}".format( + item=_("Item"), item_code=item.item_code, + returned=_("Max Returnable Qty"), qty=returnable_qty)) + def get_already_returned_item_qty(self, ref_fieldname): return dict(webnotes.conn.sql("""select item_code, sum(transfer_qty) as qty from `tabStock Entry Detail` where parent in ( From 4cae8a0d54dbed6036e793a1a406db5024090267 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 10:47:34 +0530 Subject: [PATCH 2/7] Fixes in stock ledger report --- stock/report/stock_ledger/stock_ledger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stock/report/stock_ledger/stock_ledger.py b/stock/report/stock_ledger/stock_ledger.py index 94c8eeda16..38308c2f31 100644 --- a/stock/report/stock_ledger/stock_ledger.py +++ b/stock/report/stock_ledger/stock_ledger.py @@ -62,9 +62,10 @@ def get_item_conditions(filters): def get_sle_conditions(filters): conditions = [] - if filters.get("item_code"): + item_conditions=get_item_conditions(filters) + if item_conditions: conditions.append("""item_code in (select name from tabItem - {item_conditions})""".format(item_conditions=get_item_conditions(filters))) + {item_conditions})""".format(item_conditions=item_conditions)) if filters.get("warehouse"): conditions.append("warehouse=%(warehouse)s") if filters.get("voucher_no"): From a3d058938e5981f5dd146a35d5c2b335e3ef3c39 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 11:03:04 +0530 Subject: [PATCH 3/7] Company mandatory validation while enabling perpetual inventory --- .../doctype/accounts_settings/accounts_settings.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/accounts/doctype/accounts_settings/accounts_settings.py b/accounts/doctype/accounts_settings/accounts_settings.py index d55b022d2f..a6e993863d 100644 --- a/accounts/doctype/accounts_settings/accounts_settings.py +++ b/accounts/doctype/accounts_settings/accounts_settings.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cint, cstr -from webnotes import msgprint, _ +from webnotes import _ class DocType: def __init__(self, d, dl): @@ -16,6 +15,11 @@ class DocType: webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock) if self.doc.auto_accounting_for_stock: - for wh in webnotes.conn.sql("select name from `tabWarehouse`"): - wh_bean = webnotes.bean("Warehouse", wh[0]) + warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1) + warehouse_with_no_company = [d.name for d in warehouse_list if not d.company] + if warehouse_with_no_company: + webnotes.throw(_("Company is missing in following warehouses") + ": \n" + + "\n".join(warehouse_with_no_company)) + for wh in warehouse_list: + wh_bean = webnotes.bean("Warehouse", wh.name) wh_bean.save() \ No newline at end of file From 25a4bd02f43be98b0b4fba085b669818dada6d1d Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 24 Dec 2013 11:32:57 +0530 Subject: [PATCH 4/7] [fix] [minor] update item_name and description in item price --- patches/1312/p02_update_item_details_in_item_price.py | 10 ++++++++++ patches/patch_list.py | 1 + 2 files changed, 11 insertions(+) create mode 100644 patches/1312/p02_update_item_details_in_item_price.py diff --git a/patches/1312/p02_update_item_details_in_item_price.py b/patches/1312/p02_update_item_details_in_item_price.py new file mode 100644 index 0000000000..c19988c9ef --- /dev/null +++ b/patches/1312/p02_update_item_details_in_item_price.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.conn.sql("""update `tabItem Price` ip INNER JOIN `tabItem` i + ON (ip.item_code = i.name) + set ip.item_name = i.item_name, ip.item_description = i.description""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 49c0779872..608ba77168 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -262,4 +262,5 @@ patch_list = [ "patches.1311.p07_scheduler_errors_digest", "patches.1311.p08_email_digest_recipients", "execute:webnotes.delete_doc('DocType', 'Warehouse Type')", + "patches.1312.p02_update_item_details_in_item_price", ] \ No newline at end of file From 6a2edee91453cde85b2f8f547c910462ff9665a1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 11:58:05 +0530 Subject: [PATCH 5/7] Fixes in general ledger report --- accounts/report/general_ledger/general_ledger.py | 12 +++++++----- setup/doctype/features_setup/features_setup.txt | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index e76c0c4bf9..b88d5bc296 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -9,8 +9,9 @@ from accounts.utils import get_balance_on def execute(filters=None): account_details = webnotes.conn.get_value("Account", filters["account"], - ["debit_or_credit", "group_or_ledger"], as_dict=True) - validate_filters(filters, account_details.group_or_ledger) + ["debit_or_credit", "group_or_ledger"], as_dict=True) if filters.get("account") else None + validate_filters(filters, account_details) + columns = get_columns() data = [] if filters.get("group_by"): @@ -20,14 +21,15 @@ def execute(filters=None): if data: data.append(get_total_row(data)) - if filters.get("account"): + if account_details: data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \ [get_closing_balance_row(filters, account_details.debit_or_credit)] return columns, data -def validate_filters(filters, group_or_ledger): - if group_or_ledger == "Ledger" and filters.get("group_by") == "Group by Account": +def validate_filters(filters, account_details): + if account_details and account_details.group_or_ledger == "Ledger" \ + and filters.get("group_by") == "Group by Account": webnotes.throw(_("Can not filter based on Account, if grouped by Account")) if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher": diff --git a/setup/doctype/features_setup/features_setup.txt b/setup/doctype/features_setup/features_setup.txt index 3f73ee2e25..d68f489af7 100644 --- a/setup/doctype/features_setup/features_setup.txt +++ b/setup/doctype/features_setup/features_setup.txt @@ -2,7 +2,7 @@ { "creation": "2012-12-20 12:50:49", "docstatus": 0, - "modified": "2013-11-03 14:20:18", + "modified": "2013-12-24 11:40:19", "modified_by": "Administrator", "owner": "Administrator" }, @@ -90,7 +90,7 @@ "doctype": "DocField", "fieldname": "fs_packing_details", "fieldtype": "Check", - "label": "Packing Detials" + "label": "Packing Details" }, { "description": "To get Item Group in details table", From 6ebcc5c0069e0b70c7eef2a0536ea4fe66a8b1ad Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 12:14:12 +0530 Subject: [PATCH 6/7] Change parent account of warehouse from inside the warehouse --- stock/doctype/warehouse/warehouse.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 8b1b5b5a1d..db4ee405f5 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -20,6 +20,19 @@ class DocType: if self.doc.email_id and not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Id", raise_exception=1) + self.update_parent_account() + + def update_parent_account(self): + if not self.doc.__islocal and (self.doc.create_account_under != + webnotes.conn.get_value("Warehouse", self.doc.name, "create_account_under")): + warehouse_account = webnotes.conn.get_value("Account", + {"account_type": "Warehouse", "company": self.doc.company, + "master_name": self.doc.name}, ["name", "parent_account"]) + if warehouse_account and warehouse_account[1] != self.doc.create_account_under: + acc_bean = webnotes.bean("Account", warehouse_account[0]) + acc_bean.doc.parent_account = self.doc.create_account_under + acc_bean.save() + def on_update(self): self.create_account_head() From a402079cd479932b13c993750a2728ab870e0dbf Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 24 Dec 2013 13:42:21 +0600 Subject: [PATCH 7/7] bumped to version 3.3.8 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 55c776ad0a..b57ba61ba1 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.7", + "app_version": "3.3.8", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": {