Merge pull request #39312 from frappe/mergify/bp/version-15-hotfix/pr-39299

fix: circular dependency error on deletion of QC and Stock Entry (backport #39299)
This commit is contained in:
rohitwaghchaure 2024-01-11 15:14:34 +05:30 committed by GitHub
commit 3f4cf15def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -111,6 +111,9 @@ class QualityInspection(Document):
def on_cancel(self):
self.update_qc_reference()
def on_trash(self):
self.update_qc_reference()
def validate_readings_status_mandatory(self):
for reading in self.readings:
if not reading.status:

View File

@ -250,6 +250,33 @@ class TestQualityInspection(FrappeTestCase):
qa.delete()
dn.delete()
def test_delete_quality_inspection_linked_with_stock_entry(self):
item_code = create_item("_Test Cicuular Dependecy Item with QA").name
se = make_stock_entry(
item_code=item_code, target="_Test Warehouse - _TC", qty=1, basic_rate=100, do_not_submit=True
)
se.inspection_required = 1
se.save()
qa = create_quality_inspection(
item_code=item_code, reference_type="Stock Entry", reference_name=se.name, do_not_submit=True
)
se.reload()
se.items[0].quality_inspection = qa.name
se.save()
qa.delete()
se.reload()
qc = se.items[0].quality_inspection
self.assertFalse(qc)
se.delete()
def create_quality_inspection(**args):
args = frappe._dict(args)