Merge pull request #3037 from neilLasrado/production-planning
Production planning
This commit is contained in:
commit
53bc304be2
@ -204,12 +204,13 @@ $.extend(cur_frm.cscript, {
|
|||||||
method:"erpnext.manufacturing.doctype.production_order.production_order.make_time_log",
|
method:"erpnext.manufacturing.doctype.production_order.production_order.make_time_log",
|
||||||
args: {
|
args: {
|
||||||
"name": doc.name,
|
"name": doc.name,
|
||||||
"operation": child.idx + ". " + child.operation,
|
"operation": child.operation,
|
||||||
"from_time": child.planned_start_time,
|
"from_time": child.planned_start_time,
|
||||||
"to_time": child.planned_end_time,
|
"to_time": child.planned_end_time,
|
||||||
"project": doc.project,
|
"project": doc.project,
|
||||||
"workstation": child.workstation,
|
"workstation": child.workstation,
|
||||||
"qty": flt(doc.qty) - flt(child.completed_qty)
|
"qty": flt(doc.qty) - flt(child.completed_qty),
|
||||||
|
"operation_id": child.name
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
var doclist = frappe.model.sync(r.message);
|
var doclist = frappe.model.sync(r.message);
|
||||||
|
@ -167,19 +167,22 @@
|
|||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "",
|
"default": "now",
|
||||||
"fieldname": "planned_start_date",
|
"fieldname": "planned_start_date",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"label": "Planned Start Date",
|
"label": "Planned Start Date",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": "",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "planned_end_date",
|
"fieldname": "planned_end_date",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"label": "Planned End Date",
|
"label": "Planned End Date",
|
||||||
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_13",
|
"fieldname": "column_break_13",
|
||||||
@ -354,8 +357,8 @@
|
|||||||
"icon": "icon-cogs",
|
"icon": "icon-cogs",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-03-10 17:02:28.401930",
|
"modified": "2015-04-13 02:44:17.319988",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Order",
|
"name": "Production Order",
|
||||||
|
@ -248,6 +248,7 @@ class ProductionOrder(Document):
|
|||||||
self.planned_end_date = self.operations[-1].planned_end_time
|
self.planned_end_date = self.operations[-1].planned_end_time
|
||||||
|
|
||||||
if time_logs:
|
if time_logs:
|
||||||
|
frappe.local.message_log = []
|
||||||
frappe.msgprint(_("Time Logs created:") + "\n" + "\n".join(time_logs))
|
frappe.msgprint(_("Time Logs created:") + "\n" + "\n".join(time_logs))
|
||||||
|
|
||||||
def set_operation_start_end_time(self, i, d):
|
def set_operation_start_end_time(self, i, d):
|
||||||
|
@ -126,7 +126,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"depends_on": "eval:(doc.docstatus==1 && doc.status!=\"Completed\")",
|
"depends_on": "eval:(doc.docstatus==1)",
|
||||||
"fieldname": "show_time_logs",
|
"fieldname": "show_time_logs",
|
||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
"label": "Show Time Logs",
|
"label": "Show Time Logs",
|
||||||
@ -277,6 +277,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
"depends_on": "eval:(doc.docstatus==1 && doc.status!=\"Completed\")",
|
"depends_on": "eval:(doc.docstatus==1 && doc.status!=\"Completed\")",
|
||||||
"fieldname": "make_time_log",
|
"fieldname": "make_time_log",
|
||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
@ -292,7 +293,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-03-24 07:02:54.203235",
|
"modified": "2015-04-01 08:23:58.556092",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Order Operation",
|
"name": "Production Order Operation",
|
||||||
|
@ -41,45 +41,4 @@ frappe.ui.form.on("Time Log", "to_time", function(frm) {
|
|||||||
if(frm._setting_hours) return;
|
if(frm._setting_hours) return;
|
||||||
frm.set_value("hours", moment(cur_frm.doc.to_time).diff(moment(cur_frm.doc.from_time),
|
frm.set_value("hours", moment(cur_frm.doc.to_time).diff(moment(cur_frm.doc.from_time),
|
||||||
"hours"));
|
"hours"));
|
||||||
});
|
});
|
||||||
|
|
||||||
cur_frm.set_query("production_order", function(doc) {
|
|
||||||
return {
|
|
||||||
"filters": {
|
|
||||||
"docstatus": 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
cur_frm.add_fetch('task','project','project');
|
|
||||||
|
|
||||||
$.extend(cur_frm.cscript, {
|
|
||||||
production_order: function(doc) {
|
|
||||||
if (doc.production_order){
|
|
||||||
var operations = [];
|
|
||||||
frappe.model.with_doc("Production Order", doc.production_order, function(pro) {
|
|
||||||
doc = frappe.get_doc("Production Order",pro);
|
|
||||||
$.each(doc.operations , function(i, row){
|
|
||||||
operations[i] = row.operation;
|
|
||||||
});
|
|
||||||
frappe.meta.get_docfield("Time Log", "operation", me.frm.doc.name).options = "\n" + operations.join("\n");
|
|
||||||
refresh_field("operation");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
operation: function(doc) {
|
|
||||||
return frappe.call({
|
|
||||||
method: "erpnext.projects.doctype.time_log.time_log.get_workstation",
|
|
||||||
args: {
|
|
||||||
"production_order": doc.production_order,
|
|
||||||
"operation": doc.operation
|
|
||||||
},
|
|
||||||
callback: function(r) {
|
|
||||||
if(!r.exc) {
|
|
||||||
cur_frm.set_value("workstation", r.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
@ -117,7 +117,7 @@
|
|||||||
"options": "Production Order",
|
"options": "Production Order",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"read_only": 0
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "",
|
"depends_on": "",
|
||||||
@ -127,7 +127,7 @@
|
|||||||
"options": "Operation",
|
"options": "Operation",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"read_only": 0
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "",
|
"depends_on": "",
|
||||||
@ -155,7 +155,7 @@
|
|||||||
"options": "Workstation",
|
"options": "Workstation",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"read_only": 0
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "",
|
"depends_on": "",
|
||||||
@ -242,7 +242,7 @@
|
|||||||
"icon": "icon-time",
|
"icon": "icon-time",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-03-24 08:10:31.412670",
|
"modified": "2015-04-06 02:47:16.187046",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Time Log",
|
"name": "Time Log",
|
||||||
|
@ -206,20 +206,6 @@ class TimeLog(Document):
|
|||||||
self.operation = None
|
self.operation = None
|
||||||
self.quantity = None
|
self.quantity = None
|
||||||
|
|
||||||
@frappe.whitelist()
|
|
||||||
def get_workstation(production_order, operation):
|
|
||||||
"""Returns workstation name from Production Order against an associated Operation.
|
|
||||||
|
|
||||||
:param production_order string
|
|
||||||
:param operation string
|
|
||||||
"""
|
|
||||||
if operation:
|
|
||||||
idx, operation = operation.split('. ',1)
|
|
||||||
|
|
||||||
workstation = frappe.db.sql("""select workstation from `tabProduction Order Operation` where idx=%s and
|
|
||||||
parent=%s and operation = %s""", (idx, production_order, operation))
|
|
||||||
return workstation[0][0] if workstation else ""
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start, end, filters=None):
|
||||||
"""Returns events for Gantt / Calendar view rendering.
|
"""Returns events for Gantt / Calendar view rendering.
|
||||||
|
@ -474,8 +474,8 @@ class StockEntry(StockController):
|
|||||||
pro_doc = frappe.get_doc("Production Order", self.production_order)
|
pro_doc = frappe.get_doc("Production Order", self.production_order)
|
||||||
_validate_production_order(pro_doc)
|
_validate_production_order(pro_doc)
|
||||||
pro_doc.run_method("update_status")
|
pro_doc.run_method("update_status")
|
||||||
|
pro_doc.run_method("update_production_order_qty")
|
||||||
if self.purpose == "Manufacture":
|
if self.purpose == "Manufacture":
|
||||||
pro_doc.run_method("update_production_order_qty")
|
|
||||||
self.update_planned_qty(pro_doc)
|
self.update_planned_qty(pro_doc)
|
||||||
|
|
||||||
def update_planned_qty(self, pro_doc):
|
def update_planned_qty(self, pro_doc):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user