fix: Check if both old and new items have bundles before merging

- If only one has bundle against it, they can be merged
This commit is contained in:
marination 2022-02-23 16:26:20 +05:30
parent 857ac8c045
commit a33f04ea41
2 changed files with 6 additions and 3 deletions

View File

@ -465,9 +465,11 @@ class Item(Document):
def validate_duplicate_product_bundles_before_merge(self, old_name, new_name):
"Block merge if both old and new items have product bundles."
bundle = frappe.get_value("Product Bundle",filters={"new_item_code": old_name})
if bundle:
bundle_link = get_link_to_form("Product Bundle", bundle)
old_bundle = frappe.get_value("Product Bundle",filters={"new_item_code": old_name})
new_bundle = frappe.get_value("Product Bundle",filters={"new_item_code": new_name})
if old_bundle and new_bundle:
bundle_link = get_link_to_form("Product Bundle", old_bundle)
old_name, new_name = frappe.bold(old_name), frappe.bold(new_name)
msg = _("Please delete Product Bundle {0}, before merging {1} into {2}").format(

View File

@ -397,6 +397,7 @@ class TestItem(ERPNextTestCase):
create_item("Test Item inside Bundle")
bundle_items = ["Test Item inside Bundle"]
# make bundles for both items
bundle1 = make_product_bundle("Test Item Bundle Item 1", bundle_items, qty=2)
make_product_bundle("Test Item Bundle Item 2", bundle_items, qty=2)