diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index e20019c7be..2513947462 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -329,9 +329,6 @@ class ProductionOrder(Document): frappe.delete_doc("Time Log", time_log.name) def validate_production_item(self): - if not frappe.db.get_value("Item", self.production_item, "is_pro_applicable"): - frappe.throw(_("Item is not allowed to have Production Order."), ProductionNotApplicableError) - if frappe.db.get_value("Item", self.production_item, "has_variants"): frappe.throw(_("Production Order cannot be raised against a Item Template"), ItemHasVariantError) diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.py b/erpnext/manufacturing/doctype/production_order/test_production_order.py index cfea4e572b..980f152181 100644 --- a/erpnext/manufacturing/doctype/production_order/test_production_order.py +++ b/erpnext/manufacturing/doctype/production_order/test_production_order.py @@ -125,12 +125,6 @@ class TestProductionOrder(unittest.TestCase): self.assertEqual(prod_order.planned_operating_cost, cost*2) def test_production_item(self): - frappe.db.set_value("Item", "_Test FG Item", "is_pro_applicable", 0) - - prod_order = make_prod_order_test_record(item="_Test FG Item", qty=1, do_not_save=True) - self.assertRaises(ProductionNotApplicableError, prod_order.save) - - frappe.db.set_value("Item", "_Test FG Item", "is_pro_applicable", 1) frappe.db.set_value("Item", "_Test FG Item", "end_of_life", "2000-1-1") self.assertRaises(frappe.ValidationError, prod_order.save) diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py index e482cc3d50..a95948d32b 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -36,7 +36,7 @@ class ProductionPlanningTool(Document): so_filter += " and so.project = %(project)s" if self.fg_item: - item_filter += " and item.name = %(item)s" + item_filter += " and so_item.item_code = %(item)s" open_so = frappe.db.sql(""" select distinct so.name, so.transaction_date, so.customer, so.base_grand_total @@ -44,14 +44,14 @@ class ProductionPlanningTool(Document): where so_item.parent = so.name and so.docstatus = 1 and so.status != "Stopped" and so.company = %(company)s - and so_item.qty > so_item.delivered_qty {0} - and (exists (select name from `tabItem` item where item.name=so_item.item_code - and ((item.is_pro_applicable = 1 or item.is_sub_contracted_item = 1) {1})) + and so_item.qty > so_item.delivered_qty {0} {1} + and (exists (select name from `tabBOM` bom where bom.item=so_item.item_code + and bom.is_active = 1) or exists (select name from `tabPacked Item` pi where pi.parent = so.name and pi.parent_item = so_item.item_code - and exists (select name from `tabItem` item where item.name=pi.item_code - and (item.is_pro_applicable = 1 or item.is_sub_contracted_item = 1) {2}))) - """.format(so_filter, item_filter, item_filter), { + and exists (select name from `tabBOM` bom where bom.item=pi.item_code + and bom.is_active = 1))) + """.format(so_filter, item_filter), { "from_date": self.from_date, "to_date": self.to_date, "customer": self.customer, @@ -86,7 +86,7 @@ class ProductionPlanningTool(Document): mr_filter += " and mr_item.warehouse = %(warehouse)s" if self.fg_item: - item_filter += " and item.name = %(item)s" + item_filter += " and mr_item.item_code = %(item)s" pending_mr = frappe.db.sql(""" select distinct mr.name, mr.transaction_date @@ -94,9 +94,9 @@ class ProductionPlanningTool(Document): where mr_item.parent = mr.name and mr.material_request_type = "Manufacture" and mr.docstatus = 1 - and mr_item.qty > mr_item.ordered_qty {0} - and (exists (select name from `tabItem` item where item.name=mr_item.item_code - and (item.is_pro_applicable = 1 or item.is_sub_contracted_item = 1 {1}))) + and mr_item.qty > ifnull(mr_item.ordered_qty,0) {0} {1} + and (exists (select name from `tabBOM` bom where bom.item=mr_item.item_code + and bom.is_active = 1)) """.format(mr_filter, item_filter), { "from_date": self.from_date, "to_date": self.to_date, @@ -137,8 +137,8 @@ class ProductionPlanningTool(Document): (qty - delivered_qty) as pending_qty from `tabSales Order Item` so_item where parent in (%s) and docstatus = 1 and qty > delivered_qty - and exists (select * from `tabItem` item where item.name=so_item.item_code - and item.is_pro_applicable = 1) %s""" % \ + and exists (select name from `tabBOM` bom where bom.item=so_item.item_code + and bom.is_active = 1) %s""" % \ (", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1) if self.fg_item: @@ -151,8 +151,8 @@ class ProductionPlanningTool(Document): where so_item.parent = pi.parent and so_item.docstatus = 1 and pi.parent_item = so_item.item_code and so_item.parent in (%s) and so_item.qty > so_item.delivered_qty - and exists (select * from `tabItem` item where item.name=pi.item_code - and item.is_pro_applicable = 1) %s""" % \ + and exists (select name from `tabBOM` bom where bom.item=pi.item_code + and bom.is_active = 1) %s""" % \ (", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1) self.add_items(items + packed_items) @@ -171,8 +171,8 @@ class ProductionPlanningTool(Document): (qty - ordered_qty) as pending_qty from `tabMaterial Request Item` mr_item where parent in (%s) and docstatus = 1 and qty > ordered_qty - and exists (select * from `tabItem` item where item.name=mr_item.item_code - and item.is_pro_applicable = 1) %s""" % \ + and exists (select name from `tabBOM` bom where bom.item=mr_item.item_code + and bom.is_active = 1) %s""" % \ (", ".join(["%s"] * len(mr_list)), item_condition), tuple(mr_list), as_dict=1) self.add_items(items) @@ -324,7 +324,6 @@ class ProductionPlanningTool(Document): fb.description, fb.stock_uom, it.min_order_qty from `tabBOM Explosion Item` fb, `tabBOM` bom, `tabItem` it where bom.name = fb.parent and it.name = fb.item_code - and (is_pro_applicable = 0 or ifnull(default_bom, "")="") and (is_sub_contracted_item = 0 or ifnull(default_bom, "")="") and is_stock_item = 1 and fb.docstatus<2 and bom.name=%s diff --git a/erpnext/patches/v5_2/change_item_selects_to_checks.py b/erpnext/patches/v5_2/change_item_selects_to_checks.py index 9871b6a6d7..dde0b56eeb 100644 --- a/erpnext/patches/v5_2/change_item_selects_to_checks.py +++ b/erpnext/patches/v5_2/change_item_selects_to_checks.py @@ -4,7 +4,7 @@ import frappe def execute(): fields = ("is_stock_item", "is_asset_item", "has_batch_no", "has_serial_no", - "inspection_required", "is_pro_applicable", "is_sub_contracted_item") + "inspection_required", "is_sub_contracted_item") # convert to 1 or 0 diff --git a/erpnext/public/js/utils/item_selector.js b/erpnext/public/js/utils/item_selector.js index 7d0bd15954..87d2fc8511 100644 --- a/erpnext/public/js/utils/item_selector.js +++ b/erpnext/public/js/utils/item_selector.js @@ -15,6 +15,7 @@ erpnext.ItemSelector = Class.extend({ } me.dialog.show(); me.render_items(); + setTimeout(function() { me.dialog.input.focus(); }, 1000); }); } }, diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 9d74e2a00c..7ac8941808 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -238,9 +238,9 @@ class TestSalesOrder(unittest.TestCase): from erpnext.stock.doctype.item.test_item import make_item from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle - make_item("_Test Service Product Bundle", {"is_stock_item": 0, "is_pro_applicable": 0}) - make_item("_Test Service Product Bundle Item 1", {"is_stock_item": 0, "is_pro_applicable": 0}) - make_item("_Test Service Product Bundle Item 2", {"is_stock_item": 0, "is_pro_applicable": 0}) + make_item("_Test Service Product Bundle", {"is_stock_item": 0}) + make_item("_Test Service Product Bundle Item 1", {"is_stock_item": 0}) + make_item("_Test Service Product Bundle Item 2", {"is_stock_item": 0}) make_product_bundle("_Test Service Product Bundle", ["_Test Service Product Bundle Item 1", "_Test Service Product Bundle Item 2"]) @@ -254,9 +254,9 @@ class TestSalesOrder(unittest.TestCase): from erpnext.stock.doctype.item.test_item import make_item from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle - make_item("_Test Mix Product Bundle", {"is_stock_item": 0, "is_pro_applicable": 0}) + make_item("_Test Mix Product Bundle", {"is_stock_item": 0}) make_item("_Test Mix Product Bundle Item 1", {"is_stock_item": 1}) - make_item("_Test Mix Product Bundle Item 2", {"is_stock_item": 0, "is_pro_applicable": 0}) + make_item("_Test Mix Product Bundle Item 2", {"is_stock_item": 0}) make_product_bundle("_Test Mix Product Bundle", ["_Test Mix Product Bundle Item 1", "_Test Mix Product Bundle Item 2"]) @@ -265,7 +265,7 @@ class TestSalesOrder(unittest.TestCase): def test_auto_insert_price(self): from erpnext.stock.doctype.item.test_item import make_item - make_item("_Test Item for Auto Price List", {"is_stock_item": 0, "is_pro_applicable": 0}) + make_item("_Test Item for Auto Price List", {"is_stock_item": 0}) frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 1) item_price = frappe.db.get_value("Item Price", {"price_list": "_Test Price List", @@ -299,7 +299,7 @@ class TestSalesOrder(unittest.TestCase): from erpnext.stock.doctype.item.test_item import make_item from erpnext.buying.doctype.purchase_order.purchase_order import update_status - po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1, + po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1, 'default_supplier': '_Test Supplier', "expense_account": "_Test Account Cost for Goods Sold - _TC", "cost_center": "_Test Cost Center - _TC" @@ -333,7 +333,7 @@ class TestSalesOrder(unittest.TestCase): existing_ordered_qty = bin[0].ordered_qty if bin else 0.0 existing_reserved_qty = bin[0].reserved_qty if bin else 0.0 - bin = frappe.get_all("Bin", filters={"item_code": dn_item.item_code, + bin = frappe.get_all("Bin", filters={"item_code": dn_item.item_code, "warehouse": "_Test Warehouse - _TC"}, fields=["reserved_qty"]) existing_reserved_qty_for_dn_item = bin[0].reserved_qty if bin else 0.0 @@ -341,7 +341,7 @@ class TestSalesOrder(unittest.TestCase): #create so, po and partial dn so = make_sales_order(item_list=so_items, do_not_submit=True) so.submit() - + po = make_purchase_order_for_drop_shipment(so.name, '_Test Supplier') po.submit() @@ -420,10 +420,10 @@ class TestSalesOrder(unittest.TestCase): so.items[0].margin_type = 'Percentage' so.items[0].margin_rate_or_amount = 25 so.insert() - + new_so = frappe.copy_doc(so) new_so.save(ignore_permissions=True) - + self.assertEquals(new_so.get("items")[0].rate, flt((price_list_rate*25)/100 + price_list_rate)) new_so.items[0].margin_rate_or_amount = 25 new_so.submit() diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py index 780fa976e0..542eb0b9e3 100644 --- a/erpnext/setup/setup_wizard/setup_wizard.py +++ b/erpnext/setup/setup_wizard/setup_wizard.py @@ -277,7 +277,6 @@ def create_items(args): is_sales_item = args.get("is_sales_item_" + str(i)) is_purchase_item = args.get("is_purchase_item_" + str(i)) is_stock_item = item_group!=_("Services") - is_pro_applicable = item_group!=_("Services") default_warehouse = "" if is_stock_item: default_warehouse = frappe.db.get_value("Warehouse", filters={ @@ -293,7 +292,6 @@ def create_items(args): "description": item, "show_in_website": 1, "is_stock_item": is_stock_item and 1 or 0, - "is_pro_applicable": is_pro_applicable and 1 or 0, "item_group": item_group, "stock_uom": args.get("item_uom_" + str(i)), "default_warehouse": default_warehouse diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index b9b556937f..c1fad75c71 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -1683,26 +1683,24 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "default": "", "depends_on": "", - "description": "", - "fieldname": "is_pro_applicable", - "fieldtype": "Check", + "fieldname": "default_bom", + "fieldtype": "Link", "hidden": 0, - "ignore_user_permissions": 0, + "ignore_user_permissions": 1, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Allow Production Order", + "label": "Default BOM", "length": 0, - "no_copy": 0, - "oldfieldname": "is_pro_applicable", - "oldfieldtype": "Select", - "options": "", + "no_copy": 1, + "oldfieldname": "default_bom", + "oldfieldtype": "Link", + "options": "BOM", "permlevel": 0, "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -1762,34 +1760,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "depends_on": "", - "fieldname": "default_bom", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Default BOM", - "length": 0, - "no_copy": 1, - "oldfieldname": "default_bom", - "oldfieldtype": "Link", - "options": "BOM", - "permlevel": 0, - "print_hide": 0, - "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": 0, "bold": 0, @@ -2235,7 +2205,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2016-04-15 11:18:48.948958", + "modified": "2016-04-15 04:53:25.076425", "modified_by": "Administrator", "module": "Stock", "name": "Item", @@ -2402,6 +2372,7 @@ "write": 0 } ], + "quick_entry": 0, "read_only": 0, "read_only_onload": 0, "search_fields": "item_name,description,item_group,customer_code", diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 2f92dd9d3e..d8a3115db5 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -54,7 +54,7 @@ class Item(WebsiteGenerator): self.description = self.item_name self.publish_in_hub = 1 - + def validate(self): super(Item, self).validate() @@ -348,9 +348,6 @@ class Item(WebsiteGenerator): frappe.throw(_("Conversion factor for default Unit of Measure must be 1 in row {0}").format(d.idx)) def validate_item_type(self): - if self.is_pro_applicable == 1 and self.is_stock_item==0: - self.is_pro_applicable = 0 - if self.has_serial_no == 1 and self.is_stock_item == 0: msgprint(_("'Has Serial No' can not be 'Yes' for non-stock item"), raise_exception=1) diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index 6456d03342..39c5258a0f 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -212,7 +212,7 @@ def make_purchase_order(source_name, target_doc=None): }, target_doc, postprocess) return doclist - + @frappe.whitelist() def make_request_for_quotation(source_name, target_doc=None): doclist = get_mapped_doc("Material Request", source_name, { @@ -363,8 +363,8 @@ def raise_production_orders(material_request): errors =[] production_orders = [] for d in mr.items: - if (d.qty - d.ordered_qty) >0 : - if frappe.db.get_value("Item", d.item_code, "is_pro_applicable"): + if (d.qty - d.ordered_qty) >0: + if frappe.db.get_value("BOM", {"item": d.item_code, "is_default": 1}): prod_order = frappe.new_doc("Production Order") prod_order.production_item = d.item_code prod_order.qty = d.qty - d.ordered_qty