test: add test case for item master maintain-stock
This commit is contained in:
parent
7b878ea3d8
commit
bf1fa014f4
@ -786,6 +786,36 @@ class TestItem(FrappeTestCase):
|
|||||||
item.save()
|
item.save()
|
||||||
self.assertTrue(len(item.customer_code) > 140)
|
self.assertTrue(len(item.customer_code) > 140)
|
||||||
|
|
||||||
|
def test_update_is_stock_item(self):
|
||||||
|
# Step - 1: Create an Item with Maintain Stock enabled
|
||||||
|
item = make_item(properties={"is_stock_item": 1})
|
||||||
|
|
||||||
|
# Step - 2: Disable Maintain Stock
|
||||||
|
item.is_stock_item = 0
|
||||||
|
item.save()
|
||||||
|
item.reload()
|
||||||
|
self.assertEqual(item.is_stock_item, 0)
|
||||||
|
|
||||||
|
# Step - 3: Create Product Bundle
|
||||||
|
pb = frappe.new_doc("Product Bundle")
|
||||||
|
pb.new_item_code = item.name
|
||||||
|
pb.flags.ignore_mandatory = True
|
||||||
|
pb.save()
|
||||||
|
|
||||||
|
# Step - 4: Try to enable Maintain Stock, should throw a validation error
|
||||||
|
item.is_stock_item = 1
|
||||||
|
self.assertRaises(frappe.ValidationError, item.save)
|
||||||
|
item.reload()
|
||||||
|
|
||||||
|
# Step - 5: Delete Product Bundle
|
||||||
|
pb.delete()
|
||||||
|
|
||||||
|
# Step - 6: Again try to enable Maintain Stock
|
||||||
|
item.is_stock_item = 1
|
||||||
|
item.save()
|
||||||
|
item.reload()
|
||||||
|
self.assertEqual(item.is_stock_item, 1)
|
||||||
|
|
||||||
|
|
||||||
def set_item_variant_settings(fields):
|
def set_item_variant_settings(fields):
|
||||||
doc = frappe.get_doc("Item Variant Settings")
|
doc = frappe.get_doc("Item Variant Settings")
|
||||||
|
Loading…
Reference in New Issue
Block a user