diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 1859cf5005..0323c2faf0 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -41,10 +41,6 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm})); -cur_frm.cscript.uom = function(doc, cdt, cdn) { - // no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation -} - cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, cdt, cdn) { return{ diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index b6a337683d..206dfa3026 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.utils import flt from frappe.model.mapper import get_mapped_doc from erpnext.controllers.buying_controller import BuyingController @@ -62,7 +63,7 @@ def make_purchase_order(source_name, target_doc=None): target.run_method("calculate_taxes_and_totals") def update_item(obj, target, source_parent): - target.conversion_factor = 1 + target.stock_qty = flt(obj.qty) * flt(obj.conversion_factor) doclist = get_mapped_doc("Supplier Quotation", source_name, { "Supplier Quotation": { @@ -76,8 +77,6 @@ def make_purchase_order(source_name, target_doc=None): "field_map": [ ["name", "supplier_quotation_item"], ["parent", "supplier_quotation"], - ["uom", "stock_uom"], - ["uom", "uom"], ["material_request", "material_request"], ["material_request_item", "material_request_item"] ], diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json index 2f4b39026a..73ebf23005 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json @@ -303,6 +303,33 @@ "unique": 0, "width": "60px" }, + { + "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_list_view": 1, + "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, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -409,6 +436,32 @@ "unique": 0, "width": "100px" }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "conversion_factor", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "UOM Conversion Factor", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -1106,6 +1159,57 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "section_break_44", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "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_list_view": 0, + "label": "Qty as per Stock UOM", + "length": 0, + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 1, "bold": 0, @@ -1144,7 +1248,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-08-26 04:51:44.857545", + "modified": "2016-09-06 02:40:11.022104", "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation Item", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 68c82be716..0706a2cd01 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -323,3 +323,4 @@ erpnext.patches.v7_0.update_missing_employee_in_timesheet erpnext.patches.v7_0.update_status_for_timesheet erpnext.patches.v7_0.set_party_name_in_payment_entry erpnext.patches.v7_1.set_student_guardian +erpnext.patches.v7_0.update_conversion_factor_in_supplier_quotation_item \ No newline at end of file diff --git a/erpnext/patches/v7_0/update_conversion_factor_in_supplier_quotation_item.py b/erpnext/patches/v7_0/update_conversion_factor_in_supplier_quotation_item.py new file mode 100644 index 0000000000..24da4b1aeb --- /dev/null +++ b/erpnext/patches/v7_0/update_conversion_factor_in_supplier_quotation_item.py @@ -0,0 +1,19 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc('buying', 'doctype', 'supplier_quotation_item') + + frappe.db.sql("""update + `tabSupplier Quotation Item` as sqi_t, + (select sqi.item_code as item_code, sqi.uom as uom, ucd.conversion_factor as conversion_factor + from `tabSupplier Quotation Item` sqi left join `tabUOM Conversion Detail` ucd + on ucd.uom = sqi.uom and sqi.item_code = ucd.parent) as conversion_data, + `tabItem` as item + set + sqi_t.conversion_factor= ifnull(conversion_data.conversion_factor, 1), + sqi_t.stock_qty = (ifnull(conversion_data.conversion_factor, 1) * sqi_t.qty), + sqi_t.stock_uom = item.stock_uom + where + sqi_t.item_code = conversion_data.item_code and + sqi_t.uom = conversion_data.uom and sqi_t.item_code = item.name""") \ No newline at end of file