Validation added in Production Order to prevent PO against Item Template or if Allow PO is No in Item Master
This commit is contained in:
parent
ccb9117ba5
commit
e233f0e2ff
@ -250,7 +250,8 @@ cur_frm.cscript['Update Finished Goods'] = function() {
|
|||||||
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
filters:[
|
filters:[
|
||||||
['Item', 'is_pro_applicable', '=', 'Yes']
|
['Item', 'is_pro_applicable', '=', 'Yes'],
|
||||||
|
['Item', 'has_variants', '=', 'No']
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ class ProductionOrder(Document):
|
|||||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||||
"In Process", "Completed", "Cancelled"])
|
"In Process", "Completed", "Cancelled"])
|
||||||
|
|
||||||
|
self.validate_production_item()
|
||||||
if self.bom_no:
|
if self.bom_no:
|
||||||
validate_bom_no(self.production_item, self.bom_no)
|
validate_bom_no(self.production_item, self.bom_no)
|
||||||
|
|
||||||
@ -319,6 +320,13 @@ class ProductionOrder(Document):
|
|||||||
def delete_time_logs(self):
|
def delete_time_logs(self):
|
||||||
for time_log in frappe.get_all("Time Log", ["name"], {"production_order": self.name}):
|
for time_log in frappe.get_all("Time Log", ["name"], {"production_order": self.name}):
|
||||||
frappe.delete_doc("Time Log", time_log.name)
|
frappe.delete_doc("Time Log", time_log.name)
|
||||||
|
|
||||||
|
def validate_production_item(self):
|
||||||
|
if frappe.db.get_value("Item", self.production_item, "is_pro_applicable")=='No':
|
||||||
|
frappe.throw(_("Item is not allowed to have Production Order."))
|
||||||
|
|
||||||
|
if frappe.db.get_value("Item", self.production_item, "has_variants"):
|
||||||
|
frappe.throw(_("Production Order cannot be raised against a Item Template"))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_details(item):
|
def get_item_details(item):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user