test cases sucess
This commit is contained in:
parent
1fa3f7d81e
commit
0c8411d085
@ -14,6 +14,7 @@ from erpnext.stock import get_warehouse_account_map
|
||||
|
||||
class QualityInspectionRequiredError(frappe.ValidationError): pass
|
||||
class QualityInspectionRejectedError(frappe.ValidationError): pass
|
||||
class QualityInspectionNotSubmittedError(frappe.ValidationError): pass
|
||||
|
||||
class StockController(AccountsController):
|
||||
def validate(self):
|
||||
@ -338,18 +339,21 @@ class StockController(AccountsController):
|
||||
qa_required = True
|
||||
elif self.doctype == "Stock Entry" and not d.quality_inspection and d.t_warehouse:
|
||||
qa_required = True
|
||||
if self.docstatus == 1 and d.quality_inspection:
|
||||
qa_doc = frappe.get_doc("Quality Inspection", d.quality_inspection)
|
||||
if qa_doc.docstatus == 0:
|
||||
link = frappe.utils.get_link_to_form('Quality Inspection', d.quality_inspection)
|
||||
frappe.msgprint(_("Quality Inspection: {0} is not submitted for the item: {1} in row {2}").format(link, d.item_code, d.idx))
|
||||
raise QualityInspectionNotSubmittedError
|
||||
|
||||
if qa_required:
|
||||
qa_failed = any([r.status=="Rejected" for r in qa_doc.readings])
|
||||
if qa_failed:
|
||||
frappe.throw(_("Row {0}: Quality Inspection rejected for item {1}")
|
||||
.format(d.idx, d.item_code), QualityInspectionRejectedError)
|
||||
elif qa_required :
|
||||
frappe.msgprint(_("Quality Inspection required for Item {0}").format(d.item_code))
|
||||
if self.docstatus==1:
|
||||
raise QualityInspectionRequiredError
|
||||
elif self.docstatus == 1:
|
||||
if d.quality_inspection:
|
||||
qa_doc = frappe.get_doc("Quality Inspection", d.quality_inspection)
|
||||
qa_failed = any([r.status=="Rejected" for r in qa_doc.readings])
|
||||
if qa_failed:
|
||||
frappe.throw(_("Row {0}: Quality Inspection rejected for item {1}")
|
||||
.format(d.idx, d.item_code), QualityInspectionRejectedError)
|
||||
|
||||
|
||||
def update_blanket_order(self):
|
||||
|
@ -147,7 +147,7 @@ def adjust_qty_for_expired_items(data):
|
||||
if item.get('has_batch_no') and item.get('website_warehouse'):
|
||||
stock_qty_dict = get_qty_in_stock(
|
||||
item.get('name'), 'website_warehouse', item.get('website_warehouse'))
|
||||
qty = stock_qty_dict.stock_qty[0][0]
|
||||
qty = stock_qty_dict.stock_qty[0][0] if stock_qty_dict.stock_qty else 0
|
||||
item['in_stock'] = 1 if qty else 0
|
||||
adjusted_data.append(item)
|
||||
|
||||
|
@ -6,7 +6,7 @@ import unittest
|
||||
from frappe.utils import nowdate
|
||||
from erpnext.stock.doctype.item.test_item import create_item
|
||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||
from erpnext.controllers.stock_controller import QualityInspectionRejectedError, QualityInspectionRequiredError
|
||||
from erpnext.controllers.stock_controller import QualityInspectionRejectedError, QualityInspectionRequiredError, QualityInspectionNotSubmittedError
|
||||
|
||||
# test_records = frappe.get_test_records('Quality Inspection')
|
||||
|
||||
@ -19,7 +19,7 @@ class TestQualityInspection(unittest.TestCase):
|
||||
dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True)
|
||||
self.assertRaises(QualityInspectionRequiredError, dn.submit)
|
||||
|
||||
qa = create_quality_inspection(reference_type="Delivery Note", reference_name=dn.name, status="Rejected")
|
||||
qa = create_quality_inspection(reference_type="Delivery Note", reference_name=dn.name, status="Rejected", submit=True)
|
||||
dn.reload()
|
||||
self.assertRaises(QualityInspectionRejectedError, dn.submit)
|
||||
|
||||
@ -27,6 +27,12 @@ class TestQualityInspection(unittest.TestCase):
|
||||
dn.reload()
|
||||
dn.submit()
|
||||
|
||||
def test_qa_not_submit(self):
|
||||
dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True)
|
||||
qa = create_quality_inspection(reference_type="Delivery Note", reference_name=dn.name, submit = False)
|
||||
dn.items[0].quality_inspection = qa.name
|
||||
self.assertRaises(QualityInspectionNotSubmittedError, dn.submit)
|
||||
|
||||
def create_quality_inspection(**args):
|
||||
args = frappe._dict(args)
|
||||
qa = frappe.new_doc("Quality Inspection")
|
||||
@ -42,6 +48,7 @@ def create_quality_inspection(**args):
|
||||
"status": args.status
|
||||
})
|
||||
qa.save()
|
||||
qa.submit()
|
||||
if args.submit:
|
||||
qa.submit()
|
||||
|
||||
return qa
|
||||
|
Loading…
x
Reference in New Issue
Block a user