fix: circular dependency error while deleting QC

(cherry picked from commit 7cc324e31ebf533b0ffde8a2a3c4013756959d7a)
This commit is contained in:
Rohit Waghchaure 2024-01-10 20:26:51 +05:30 committed by Mergify
parent d882305c72
commit 7ca8e49b38
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)