Test Cases Added to Production Order

This commit is contained in:
Neil Trini Lasrado 2015-07-21 15:30:31 +05:30
parent 9c3dca63fa
commit 21647974c4
2 changed files with 21 additions and 4 deletions

View File

@ -14,6 +14,8 @@ from erpnext.stock.doctype.item.item import validate_end_of_life
class OverProductionError(frappe.ValidationError): pass
class StockOverProductionError(frappe.ValidationError): pass
class OperationTooLongError(frappe.ValidationError): pass
class ProductionNotApplicableError(frappe.ValidationError): pass
class ItemHasVariantError(frappe.ValidationError): pass
from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError, NotInWorkingHoursError
from erpnext.projects.doctype.time_log.time_log import OverlapError
@ -326,10 +328,10 @@ class ProductionOrder(Document):
def validate_production_item(self):
if frappe.db.get_value("Item", self.production_item, "is_pro_applicable")=='No':
frappe.throw(_("Item is not allowed to have Production Order."))
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"))
frappe.throw(_("Production Order cannot be raised against a Item Template"), ItemHasVariantError)
validate_end_of_life(self.production_item)

View File

@ -7,7 +7,8 @@ import unittest
import frappe
from frappe.utils import flt, get_datetime, time_diff_in_hours
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
from erpnext.manufacturing.doctype.production_order.production_order import make_stock_entry, make_time_log
from erpnext.manufacturing.doctype.production_order.production_order \
import make_stock_entry, make_time_log, ProductionNotApplicableError,ItemHasVariantError
from erpnext.stock.doctype.stock_entry import test_stock_entry
from erpnext.projects.doctype.time_log.time_log import OverProductionLoggedError
@ -137,10 +138,24 @@ class TestProductionOrder(unittest.TestCase):
def test_production_item(self):
item = frappe.get_doc("Item", "_Test FG Item")
item.end_of_life =
item.is_pro_applicable= "No"
item.save()
prod_order = make_prod_order_test_record(item="_Test FG Item", qty=1, do_not_save=True)
self.assertRaises(ProductionNotApplicableError, prod_order.save)
item.is_pro_applicable= "Yes"
item.end_of_life = "2000-1-1"
item.save()
self.assertRaises(frappe.ValidationError, prod_order.save)
item.end_of_life=None
item.save()
prod_order = make_prod_order_test_record(item="_Test Variant Item", qty=1, do_not_save=True)
self.assertRaises(ItemHasVariantError, prod_order.save)
def make_prod_order_test_record(**args):
args = frappe._dict(args)