Merge pull request #3614 from neilLasrado/po
Track Operations added to Production Order
This commit is contained in:
commit
7daa7900ea
@ -186,15 +186,26 @@ $.extend(cur_frm.cscript, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bom_no: function() {
|
bom_no: function() {
|
||||||
return this.frm.call({
|
if (this.frm.doc.track_operations) {
|
||||||
doc: this.frm.doc,
|
return this.frm.call({
|
||||||
method: "set_production_order_operations"
|
doc: this.frm.doc,
|
||||||
});
|
method: "set_production_order_operations"
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
qty: function() {
|
qty: function() {
|
||||||
frappe.ui.form.trigger("Production Order", 'bom_no')
|
frappe.ui.form.trigger("Production Order", 'bom_no')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
track_operations: function(doc) {
|
||||||
|
if (doc.track_operations) {
|
||||||
|
frappe.ui.form.trigger("Production Order", 'bom_no')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
doc.operations =[];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
show_time_logs: function(doc, cdt, cdn) {
|
show_time_logs: function(doc, cdt, cdn) {
|
||||||
var child = locals[cdt][cdn]
|
var child = locals[cdt][cdn]
|
||||||
|
|||||||
@ -73,6 +73,14 @@
|
|||||||
"label": "Use Multi-Level BOM",
|
"label": "Use Multi-Level BOM",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "track_operations",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Track Operations",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break1",
|
"fieldname": "column_break1",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
@ -207,7 +215,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "",
|
"depends_on": "track_operations",
|
||||||
"fieldname": "operations_section",
|
"fieldname": "operations_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Operations",
|
"label": "Operations",
|
||||||
@ -216,6 +224,7 @@
|
|||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "",
|
||||||
"fieldname": "operations",
|
"fieldname": "operations",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Operations",
|
"label": "Operations",
|
||||||
@ -225,6 +234,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "track_operations",
|
||||||
"fieldname": "section_break_22",
|
"fieldname": "section_break_22",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Operation Cost",
|
"label": "Operation Cost",
|
||||||
@ -358,7 +368,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-04-13 02:44:17.319988",
|
"modified": "2015-07-09 03:31:01.291811",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Order",
|
"name": "Production Order",
|
||||||
|
|||||||
@ -174,13 +174,17 @@ class ProductionOrder(Document):
|
|||||||
|
|
||||||
def set_production_order_operations(self):
|
def set_production_order_operations(self):
|
||||||
"""Fetch operations from BOM and set in 'Production Order'"""
|
"""Fetch operations from BOM and set in 'Production Order'"""
|
||||||
|
if not self.bom_no:
|
||||||
|
return
|
||||||
self.set('operations', [])
|
self.set('operations', [])
|
||||||
|
|
||||||
operations = frappe.db.sql("""select operation, description, workstation, idx,
|
operations = frappe.db.sql("""select operation, description, workstation, idx,
|
||||||
hour_rate, time_in_mins, "Pending" as status from `tabBOM Operation`
|
hour_rate, time_in_mins, "Pending" as status from `tabBOM Operation`
|
||||||
where parent = %s order by idx""", self.bom_no, as_dict=1)
|
where parent = %s order by idx""", self.bom_no, as_dict=1)
|
||||||
|
if operations:
|
||||||
|
self.track_operations=1
|
||||||
|
else:
|
||||||
|
self.track_operations=0
|
||||||
|
frappe.msgprint(_("Cannot 'track operations' as selected BOM does not have Operations."))
|
||||||
self.set('operations', operations)
|
self.set('operations', operations)
|
||||||
self.calculate_time()
|
self.calculate_time()
|
||||||
|
|
||||||
@ -219,14 +223,12 @@ class ProductionOrder(Document):
|
|||||||
for i, d in enumerate(self.operations):
|
for i, d in enumerate(self.operations):
|
||||||
self.set_operation_start_end_time(i, d)
|
self.set_operation_start_end_time(i, d)
|
||||||
|
|
||||||
if not d.workstation:
|
|
||||||
continue
|
|
||||||
|
|
||||||
time_log = make_time_log(self.name, d.operation, d.planned_start_time, d.planned_end_time,
|
time_log = make_time_log(self.name, d.operation, d.planned_start_time, d.planned_end_time,
|
||||||
flt(self.qty) - flt(d.completed_qty), self.project_name, d.workstation, operation_id=d.name)
|
flt(self.qty) - flt(d.completed_qty), self.project_name, d.workstation, operation_id=d.name)
|
||||||
|
|
||||||
# validate operating hours if workstation [not mandatory] is specified
|
if d.workstation:
|
||||||
self.check_operation_fits_in_working_hours(d)
|
# validate operating hours if workstation [not mandatory] is specified
|
||||||
|
self.check_operation_fits_in_working_hours(d)
|
||||||
|
|
||||||
original_start_time = time_log.from_time
|
original_start_time = time_log.from_time
|
||||||
while True:
|
while True:
|
||||||
@ -391,7 +393,7 @@ def get_events(start, end, filters=None):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_time_log(name, operation, from_time, to_time, qty=None, project=None, workstation=None, operation_id=None):
|
def make_time_log(name, operation, from_time=None, to_time=None, qty=None, project=None, workstation=None, operation_id=None):
|
||||||
time_log = frappe.new_doc("Time Log")
|
time_log = frappe.new_doc("Time Log")
|
||||||
time_log.for_manufacturing = 1
|
time_log.for_manufacturing = 1
|
||||||
time_log.from_time = from_time
|
time_log.from_time = from_time
|
||||||
|
|||||||
@ -201,6 +201,9 @@ class StockEntry(StockController):
|
|||||||
def check_if_operations_completed(self):
|
def check_if_operations_completed(self):
|
||||||
"""Check if Time Logs are completed against before manufacturing to capture operating costs."""
|
"""Check if Time Logs are completed against before manufacturing to capture operating costs."""
|
||||||
prod_order = frappe.get_doc("Production Order", self.production_order)
|
prod_order = frappe.get_doc("Production Order", self.production_order)
|
||||||
|
if not prod_order.track_operations:
|
||||||
|
return
|
||||||
|
|
||||||
for d in prod_order.get("operations"):
|
for d in prod_order.get("operations"):
|
||||||
total_completed_qty = flt(self.fg_completed_qty) + flt(prod_order.produced_qty)
|
total_completed_qty = flt(self.fg_completed_qty) + flt(prod_order.produced_qty)
|
||||||
if total_completed_qty > flt(d.completed_qty):
|
if total_completed_qty > flt(d.completed_qty):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user