Merge pull request #32205 from s-aga-r/fix/issue/31557
fix: unknown column error while updating value of maintain-stock in item master
This commit is contained in:
commit
444fda5d82
@ -945,7 +945,12 @@ class Item(Document):
|
||||
if doctype == "Product Bundle":
|
||||
filters = {"new_item_code": self.name}
|
||||
|
||||
if doctype in (
|
||||
if linked_doc := frappe.db.get_value(
|
||||
doctype, filters, ["new_item_code as docname"], as_dict=True
|
||||
):
|
||||
return linked_doc.update({"doctype": doctype})
|
||||
|
||||
elif doctype in (
|
||||
"Purchase Invoice Item",
|
||||
"Sales Invoice Item",
|
||||
):
|
||||
|
@ -786,6 +786,36 @@ class TestItem(FrappeTestCase):
|
||||
item.save()
|
||||
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):
|
||||
doc = frappe.get_doc("Item Variant Settings")
|
||||
|
Loading…
Reference in New Issue
Block a user