diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 6102d3ea301..a96446f306c 100755 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, "autoname": "hash", @@ -335,6 +336,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "stock_uom", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Stock UOM", + "length": 0, + "no_copy": 0, + "options": "UOM", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -419,6 +450,35 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "stock_qty", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Stock Qty", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -1869,17 +1929,17 @@ "unique": 0 } ], + "has_web_view": 0, "hide_heading": 0, "hide_toolbar": 0, "idx": 1, "image_view": 0, "in_create": 0, - "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-02-17 16:28:26.719053", + "modified": "2017-04-11 13:44:17.460674", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 23bc531cf03..c5db2239b3e 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -140,20 +140,16 @@ def period_wise_columns_query(filters, trans): else: trans_date = 'transaction_date' - qty_field = "t2.stock_qty" - if trans == 'Purchase Invoice': - qty_field = "t2.qty" - if filters.get("period") != 'Yearly': for dt in bet_dates: get_period_wise_columns(dt, filters.get("period"), pwc) - query_details = get_period_wise_query(dt, trans_date, query_details, qty_field) + query_details = get_period_wise_query(dt, trans_date, query_details) else: pwc = [_(filters.get("fiscal_year")) + " ("+_("Qty") + "):Float:120", _(filters.get("fiscal_year")) + " ("+ _("Amt") + "):Currency:120"] - query_details = " SUM(%s), SUM(t2.base_net_amount),"%(qty_field) + query_details = " SUM(t2.stock_qty), SUM(t2.base_net_amount)," - query_details += 'SUM(%s), SUM(t2.base_net_amount)'%(qty_field) + query_details += 'SUM(t2.stock_qty), SUM(t2.base_net_amount)' return pwc, query_details def get_period_wise_columns(bet_dates, period, pwc): @@ -164,10 +160,10 @@ def get_period_wise_columns(bet_dates, period, pwc): pwc += [_(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Qty") + "):Float:120", _(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Amt") + "):Currency:120"] -def get_period_wise_query(bet_dates, trans_date, query_details, qty_field): - query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', %(qty_field)s, NULL)), +def get_period_wise_query(bet_dates, trans_date, query_details): + query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.stock_qty, NULL)), SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_net_amount, NULL)), - """ % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1], "qty_field": qty_field} + """ % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]} return query_details @frappe.whitelist(allow_guest=True) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 3711bc82b2d..5bf0f3fdfe8 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -382,4 +382,5 @@ erpnext.patches.v7_2.make_all_assessment_group erpnext.patches.v8_0.manufacturer_childtable_migrate erpnext.patches.v8_0.repost_reserved_qty_for_multiple_sales_uom erpnext.patches.v8_0.addresses_linked_to_lead -execute:frappe.delete_doc('DocType', 'Purchase Common') \ No newline at end of file +execute:frappe.delete_doc('DocType', 'Purchase Common') +erpnext.patches.v8_0.update_stock_qty_value_in_purchase_invoice \ No newline at end of file diff --git a/erpnext/patches/v8_0/update_stock_qty_value_in_purchase_invoice.py b/erpnext/patches/v8_0/update_stock_qty_value_in_purchase_invoice.py new file mode 100644 index 00000000000..be5cf3aed77 --- /dev/null +++ b/erpnext/patches/v8_0/update_stock_qty_value_in_purchase_invoice.py @@ -0,0 +1,9 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc('accounts', 'doctype', 'purchase_invoice_item') + frappe.db.sql("update `tabPurchase Invoice Item` set stock_qty = qty, stock_uom = uom") \ No newline at end of file diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index ffdc66d555a..e4bbd8744e4 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -241,7 +241,7 @@ data_map = { } }, "Purchase Invoice Item": { - "columns": ["name", "parent", "item_code", "(qty * conversion_factor) as qty", "base_net_amount"], + "columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": {