Set query sales order (#11772)
* set_query for sales order based on production_item * codacy fix * check in packed item to fetch sales order * Update production_order.py
This commit is contained in:
parent
2fb8cc5f2c
commit
c43c5cae5a
@ -167,6 +167,8 @@ frappe.ui.form.on("Production Order", {
|
|||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
|
frm.set_value('sales_order', "");
|
||||||
|
frm.trigger('set_sales_order');
|
||||||
erpnext.in_production_item_onchange = true;
|
erpnext.in_production_item_onchange = true;
|
||||||
$.each(["description", "stock_uom", "project", "bom_no"], function(i, field) {
|
$.each(["description", "stock_uom", "project", "bom_no"], function(i, field) {
|
||||||
frm.set_value(field, r.message[field]);
|
frm.set_value(field, r.message[field]);
|
||||||
@ -213,6 +215,24 @@ frappe.ui.form.on("Production Order", {
|
|||||||
before_submit: function(frm) {
|
before_submit: function(frm) {
|
||||||
frm.toggle_reqd(["fg_warehouse", "wip_warehouse"], true);
|
frm.toggle_reqd(["fg_warehouse", "wip_warehouse"], true);
|
||||||
frm.fields_dict.required_items.grid.toggle_reqd("source_warehouse", true);
|
frm.fields_dict.required_items.grid.toggle_reqd("source_warehouse", true);
|
||||||
|
},
|
||||||
|
|
||||||
|
set_sales_order: function(frm) {
|
||||||
|
if(frm.doc.production_item) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.manufacturing.doctype.production_order.production_order.query_sales_order",
|
||||||
|
args: { production_item: frm.doc.production_item },
|
||||||
|
callback: function(r) {
|
||||||
|
frm.set_query("sales_order", function() {
|
||||||
|
return {
|
||||||
|
filters: [
|
||||||
|
["Sales Order","name", "in", r.message]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -636,3 +636,15 @@ def stop_unstop(production_order, status):
|
|||||||
pro_order.notify_update()
|
pro_order.notify_update()
|
||||||
|
|
||||||
return pro_order.status
|
return pro_order.status
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def query_sales_order(production_item):
|
||||||
|
out = frappe.db.sql_list("""
|
||||||
|
select distinct so.name from `tabSales Order` so, `tabSales Order Item` so_item
|
||||||
|
where so_item.parent=so.name and so_item.item_code=%s and so.docstatus=1
|
||||||
|
union
|
||||||
|
select distinct so.name from `tabSales Order` so, `tabPacked Item` pi_item
|
||||||
|
where pi_item.parent=so.name and pi_item.item_code=%s and so.docstatus=1
|
||||||
|
""", (production_item, production_item))
|
||||||
|
|
||||||
|
return out
|
||||||
|
Loading…
x
Reference in New Issue
Block a user