From ac59c2b300c5929e1468ce8fbae78b34fb4d2646 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 16 Jun 2015 13:06:37 -0400 Subject: [PATCH 1/8] [minor] clear Item's introduction section on refresh --- erpnext/stock/doctype/item/item.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index b31b682984e..ed1367e0b61 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -55,6 +55,9 @@ frappe.ui.form.on("Item", { // read only if any stock ledger entry exists erpnext.item.make_dashboard(frm); + // clear intro + frm.set_intro(); + if (frm.doc.has_variants) { frm.set_intro(__("This Item is a Template and cannot be used in transactions. Item attributes will be copied over into the variants unless 'No Copy' is set"), true); frm.add_custom_button(__("Show Variants"), function() { @@ -85,7 +88,7 @@ frappe.ui.form.on("Item", { erpnext.item.weight_to_validate(frm); erpnext.item.variants_can_not_be_created_manually(frm); }, - + image: function(frm) { refresh_field("image_view"); }, @@ -209,11 +212,11 @@ $.extend(erpnext.item, { validated = 0; } }, - + variants_can_not_be_created_manually: function(frm) { if (frm.doc.__islocal && frm.doc.variant_of) frappe.throw(__("Variants can not be created manually, add item attributes in the template item")) } - + }); From b45a6bcb882b65c26e01baddb76c11a37a4acb07 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 17 Jun 2015 01:54:56 +0530 Subject: [PATCH 2/8] [report] BOM Search --- erpnext/config/manufacturing.py | 6 +++ erpnext/config/selling.py | 6 +++ erpnext/stock/report/bom_search/__init__.py | 0 erpnext/stock/report/bom_search/bom_search.js | 42 +++++++++++++++++++ .../stock/report/bom_search/bom_search.json | 17 ++++++++ erpnext/stock/report/bom_search/bom_search.py | 42 +++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 erpnext/stock/report/bom_search/__init__.py create mode 100644 erpnext/stock/report/bom_search/bom_search.js create mode 100644 erpnext/stock/report/bom_search/bom_search.json create mode 100644 erpnext/stock/report/bom_search/bom_search.py diff --git a/erpnext/config/manufacturing.py b/erpnext/config/manufacturing.py index c2dacad495f..5b51b0f9678 100644 --- a/erpnext/config/manufacturing.py +++ b/erpnext/config/manufacturing.py @@ -103,6 +103,12 @@ def get_data(): "name": "Completed Production Orders", "doctype": "Production Order" }, + { + "type": "report", + "is_query_report": True, + "name": "BOM Search", + "doctype": "BOM" + }, ] }, { diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index 7f8d517ae90..78c73d88227 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -237,6 +237,12 @@ def get_data(): "route": "query-report/Sales Person Target Variance Item Group-Wise", "doctype": "Sales Person", }, + { + "type": "report", + "is_query_report": True, + "name": "BOM Search", + "doctype": "BOM" + }, { "type": "report", "is_query_report": True, diff --git a/erpnext/stock/report/bom_search/__init__.py b/erpnext/stock/report/bom_search/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/stock/report/bom_search/bom_search.js b/erpnext/stock/report/bom_search/bom_search.js new file mode 100644 index 00000000000..e9e763cb889 --- /dev/null +++ b/erpnext/stock/report/bom_search/bom_search.js @@ -0,0 +1,42 @@ +// Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors and contributors +// For license information, please see license.txt + +frappe.query_reports["BOM Search"] = { + "filters": [ + { + fieldname: "item1", + label: __("Item 1"), + fieldtype: "Link", + options: "Item" + }, + { + fieldname: "item2", + label: __("Item 2"), + fieldtype: "Link", + options: "Item" + }, + { + fieldname: "item3", + label: __("Item 3"), + fieldtype: "Link", + options: "Item" + }, + { + fieldname: "item4", + label: __("Item 4"), + fieldtype: "Link", + options: "Item" + }, + { + fieldname: "item5", + label: __("Item 5"), + fieldtype: "Link", + options: "Item" + }, + { + fieldname: "search_sub_assemblies", + label: __("Search Sub Assemblies"), + fieldtype: "Check", + }, + ] +} diff --git a/erpnext/stock/report/bom_search/bom_search.json b/erpnext/stock/report/bom_search/bom_search.json new file mode 100644 index 00000000000..2857c176d3a --- /dev/null +++ b/erpnext/stock/report/bom_search/bom_search.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 0, + "apply_user_permissions": 0, + "creation": "2015-06-16 15:16:11.930954", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "is_standard": "Yes", + "modified": "2015-06-16 15:16:29.850834", + "modified_by": "Administrator", + "module": "Stock", + "name": "BOM Search", + "owner": "Administrator", + "ref_doctype": "BOM", + "report_name": "BOM Search", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/bom_search/bom_search.py b/erpnext/stock/report/bom_search/bom_search.py new file mode 100644 index 00000000000..cf1e339551c --- /dev/null +++ b/erpnext/stock/report/bom_search/bom_search.py @@ -0,0 +1,42 @@ +# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe, json + +def execute(filters=None): + data = [] + + for doctype in ("Sales BOM Item", + "BOM Explosion Item" if filters.search_sub_assemblies else "BOM Item"): + all_boms = {} + for d in frappe.get_all(doctype, fields=["parent", "item_code"]): + all_boms.setdefault(d.parent, []).append(d.item_code) + + for parent, items in all_boms.iteritems(): + valid = True + for key, item in filters.iteritems(): + if key != "search_sub_assemblies": + if item and item not in items: + valid = False + + if valid: + data.append((parent, doctype[:-5])) + + return [{ + "fieldname": "parent", + "label": "BOM", + "width": 200, + "fieldtype": "Dynamic Link", + "options": "doctype" + }, + { + "fieldname": "doctype", + "label": "Type", + "width": 200, + "fieldtype": "Data" + }], data + + #print json.dumps(all_boms, indent=1) + #columns, data = [], [] + #return columns, data From bf4547ca5fb240fe709aabac8eee78e6c5271e41 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 17 Jun 2015 02:12:06 +0530 Subject: [PATCH 3/8] [fix] dynamic link in BOM Search report --- erpnext/stock/report/bom_search/bom_search.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/bom_search/bom_search.py b/erpnext/stock/report/bom_search/bom_search.py index cf1e339551c..3e803fb0d21 100644 --- a/erpnext/stock/report/bom_search/bom_search.py +++ b/erpnext/stock/report/bom_search/bom_search.py @@ -6,6 +6,11 @@ import frappe, json def execute(filters=None): data = [] + parents = { + "Sales BOM Item": "Sales BOM", + "BOM Explosion Item": "BOM", + "BOM Item": "BOM" + } for doctype in ("Sales BOM Item", "BOM Explosion Item" if filters.search_sub_assemblies else "BOM Item"): @@ -21,7 +26,7 @@ def execute(filters=None): valid = False if valid: - data.append((parent, doctype[:-5])) + data.append((parent, parents[doctype])) return [{ "fieldname": "parent", From ed9d5cfdafe134013cf24a8cb9b723e2b45b9bb2 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 17 Jun 2015 02:13:03 +0530 Subject: [PATCH 4/8] [minor] cleanup --- erpnext/stock/report/bom_search/bom_search.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/stock/report/bom_search/bom_search.py b/erpnext/stock/report/bom_search/bom_search.py index 3e803fb0d21..b8a7b789e5f 100644 --- a/erpnext/stock/report/bom_search/bom_search.py +++ b/erpnext/stock/report/bom_search/bom_search.py @@ -41,7 +41,3 @@ def execute(filters=None): "width": 200, "fieldtype": "Data" }], data - - #print json.dumps(all_boms, indent=1) - #columns, data = [], [] - #return columns, data From bd9aa13db3fcd4ed06d937800fdf10f6c600d87f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 17 Jun 2015 15:08:43 +0530 Subject: [PATCH 5/8] Minor issue in naming series --- erpnext/setup/doctype/naming_series/naming_series.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index dc7a90cbb0b..81a4c4ec5f3 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -26,7 +26,8 @@ class NamingSeries(Document): except frappe.DoesNotExistError: continue - prefixes = prefixes + "\n" + options + if options: + prefixes = prefixes + "\n" + options prefixes.replace("\n\n", "\n") prefixes = "\n".join(sorted(prefixes.split())) From 1ac9f2f50daab7139c935ec3cb37007d974f713d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 17 Jun 2015 15:09:33 +0530 Subject: [PATCH 6/8] [fix] Opening balance in trial balance and general ledger based on is_opening --- .../report/general_ledger/general_ledger.py | 2 +- .../report/trial_balance/trial_balance.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index b268156d4c3..b6b5c8afc00 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -155,7 +155,7 @@ def get_accountwise_gle(filters, gl_entries, gle_map): for gle in gl_entries: amount = flt(gle.debit, 3) - flt(gle.credit, 3) if (filters.get("account") or filters.get("party") or filters.get("group_by_account")) \ - and gle.posting_date < from_date: + and (gle.posting_date < from_date or cstr(gle.is_opening) == "Yes"): gle_map[gle.account].opening += amount if filters.get("account") or filters.get("party"): opening += amount diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 8187601249b..1ad4a3783be 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -90,7 +90,8 @@ def get_rootwise_opening_balances(filters, report_type): where company=%(company)s {additional_conditions} - and posting_date < %(from_date)s + and (posting_date < %(from_date)s or + (posting_date >= %(from_date)s and ifnull(is_opening, 'No') = 'Yes')) and account in (select name from `tabAccount` where report_type=%(report_type)s) group by account""".format(additional_conditions=additional_conditions), { @@ -128,16 +129,21 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances, filters) for d in accounts: d.update(init.copy()) + # add opening + d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0) + d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0) + for entry in gl_entries_by_account.get(d.name, []): - d["debit"] += flt(entry.debit) - d["credit"] += flt(entry.credit) + if entry.is_opening == "Yes" and d.root_type in ("Asset", "Liability", "Equity"): + d["opening_debit"] += flt(entry.debit) + d["opening_credit"] += flt(entry.credit) + else: + d["debit"] += flt(entry.debit) + d["credit"] += flt(entry.credit) total_row["debit"] += d["debit"] total_row["credit"] += d["credit"] - # add opening - d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0) - d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0) return total_row From e91025c0aa22bff4fd71b59a2f15fd89c236ce7a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 17 Jun 2015 15:35:06 +0530 Subject: [PATCH 7/8] [fix] Opening balance in trial balance and general ledger based on is_opening --- erpnext/accounts/report/financial_statements.py | 2 +- erpnext/accounts/report/general_ledger/general_ledger.py | 2 +- erpnext/accounts/report/trial_balance/trial_balance.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index b4fec985ccc..be2e968b63c 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -210,7 +210,7 @@ def get_gl_entries(company, from_date, to_date, root_lft, root_rgt, ignore_closi if from_date: additional_conditions.append("and posting_date >= %(from_date)s") - gl_entries = frappe.db.sql("""select posting_date, account, debit, credit from `tabGL Entry` + gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening from `tabGL Entry` where company=%(company)s {additional_conditions} and posting_date <= %(to_date)s diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index b6b5c8afc00..9f1f56064db 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe -from frappe.utils import flt, getdate +from frappe.utils import flt, getdate, cstr from frappe import _ def execute(filters=None): diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 1ad4a3783be..25717511666 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -90,8 +90,7 @@ def get_rootwise_opening_balances(filters, report_type): where company=%(company)s {additional_conditions} - and (posting_date < %(from_date)s or - (posting_date >= %(from_date)s and ifnull(is_opening, 'No') = 'Yes')) + and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes') and account in (select name from `tabAccount` where report_type=%(report_type)s) group by account""".format(additional_conditions=additional_conditions), { From 495db997192e0ca58db09d38e4261e7b646c3c2a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 17 Jun 2015 16:21:00 +0600 Subject: [PATCH 8/8] bumped to version 5.0.26 --- erpnext/__version__.py | 2 +- erpnext/hooks.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/__version__.py b/erpnext/__version__.py index 32898503a2f..ca621e3c2de 100644 --- a/erpnext/__version__.py +++ b/erpnext/__version__.py @@ -1,2 +1,2 @@ from __future__ import unicode_literals -__version__ = '5.0.25' +__version__ = '5.0.26' diff --git a/erpnext/hooks.py b/erpnext/hooks.py index fa9268479c3..d36f2693f95 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -5,7 +5,7 @@ app_publisher = "Frappe Technologies Pvt. Ltd. and Contributors" app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations" app_icon = "icon-th" app_color = "#e74c3c" -app_version = "5.0.25" +app_version = "5.0.26" error_report_email = "support@erpnext.com" diff --git a/setup.py b/setup.py index 86e89f9ce64..2cba2e8914d 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "5.0.25" +version = "5.0.26" with open("requirements.txt", "r") as f: install_requires = f.readlines()