fix: add validation for QI in PR
This commit is contained in:
parent
a3ea985348
commit
2c1ab569a7
@ -122,6 +122,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
self.set_status()
|
self.set_status()
|
||||||
|
|
||||||
self.po_required()
|
self.po_required()
|
||||||
|
self.validate_items_quality_inspection()
|
||||||
self.validate_with_previous_doc()
|
self.validate_with_previous_doc()
|
||||||
self.validate_uom_is_integer("uom", ["qty", "received_qty"])
|
self.validate_uom_is_integer("uom", ["qty", "received_qty"])
|
||||||
self.validate_uom_is_integer("stock_uom", "stock_qty")
|
self.validate_uom_is_integer("stock_uom", "stock_qty")
|
||||||
@ -195,6 +196,26 @@ class PurchaseReceipt(BuyingController):
|
|||||||
if not d.purchase_order:
|
if not d.purchase_order:
|
||||||
frappe.throw(_("Purchase Order number required for Item {0}").format(d.item_code))
|
frappe.throw(_("Purchase Order number required for Item {0}").format(d.item_code))
|
||||||
|
|
||||||
|
def validate_items_quality_inspection(self):
|
||||||
|
for item in self.get("items"):
|
||||||
|
if item.quality_inspection:
|
||||||
|
qi = frappe.db.get_value(
|
||||||
|
"Quality Inspection",
|
||||||
|
item.quality_inspection,
|
||||||
|
["reference_type", "reference_name", "item_code"],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
if qi.reference_type != self.doctype or qi.reference_name != self.name:
|
||||||
|
msg = f"""Row #{item.idx}: Please select a valid Quality Inspection with Reference Type
|
||||||
|
{frappe.bold(self.doctype)} and Reference Name {frappe.bold(self.name)}."""
|
||||||
|
frappe.throw(_(msg))
|
||||||
|
|
||||||
|
if qi.item_code != item.item_code:
|
||||||
|
msg = f"""Row #{item.idx}: Please select a valid Quality Inspection with Item Code
|
||||||
|
{frappe.bold(item.item_code)}."""
|
||||||
|
frappe.throw(_(msg))
|
||||||
|
|
||||||
def get_already_received_qty(self, po, po_detail):
|
def get_already_received_qty(self, po, po_detail):
|
||||||
qty = frappe.db.sql(
|
qty = frappe.db.sql(
|
||||||
"""select sum(qty) from `tabPurchase Receipt Item`
|
"""select sum(qty) from `tabPurchase Receipt Item`
|
||||||
|
Loading…
Reference in New Issue
Block a user