[cleanup] remove is_pro_applicable

This commit is contained in:
Rushabh Mehta 2016-04-15 15:01:28 +05:30
parent 18f0dd0a6d
commit a305c29b0e
10 changed files with 45 additions and 88 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -15,6 +15,7 @@ erpnext.ItemSelector = Class.extend({
}
me.dialog.show();
me.render_items();
setTimeout(function() { me.dialog.input.focus(); }, 1000);
});
}
},

View File

@ -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",

View File

@ -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

View File

@ -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",

View File

@ -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)

View File

@ -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