[ Enhance ] Production to Work Order (#12902)

* remove occurrences of Production Order

* rename from report and jsons

* Change Production Order to Work Order

* change occurences of production order from other files

* resolve minor conflict issues and reports

* patch added

* codacy fix

* updated patches, leftover changes

* rename reports, rectify patches
This commit is contained in:
Zarrar
2018-03-20 12:38:43 +05:30
committed by Nabin Hait
parent c893268dea
commit 13ddc7e188
93 changed files with 902 additions and 710 deletions

View File

@@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Timesheet", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Timesheet
() => frappe.tests.make('Timesheet', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@@ -204,7 +204,7 @@
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:!doc.production_order || doc.docstatus == 1",
"depends_on": "eval:!doc.work_order || doc.docstatus == 1",
"fieldname": "employee_detail",
"fieldtype": "Section Break",
"hidden": 0,
@@ -421,8 +421,8 @@
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "production_order",
"fieldname": "production_detail",
"depends_on": "work_order",
"fieldname": "work_detail",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -431,7 +431,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Production Detail",
"label": "Work Detail",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -452,7 +452,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "production_order",
"fieldname": "work_order",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -461,10 +461,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Production Order",
"label": "Work Order",
"length": 0,
"no_copy": 1,
"options": "Production Order",
"options": "Work Order",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -938,7 +938,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-06-13 14:28:51.838769",
"modified": "2018-01-07 11:44:09.573900",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",

View File

@@ -16,7 +16,7 @@ from erpnext.manufacturing.doctype.workstation.workstation import (check_if_with
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
class OverlapError(frappe.ValidationError): pass
class OverProductionLoggedError(frappe.ValidationError): pass
class OverWorkLoggedError(frappe.ValidationError): pass
class Timesheet(Document):
def onload(self):
@@ -97,18 +97,18 @@ class Timesheet(Document):
self.set_status()
def on_cancel(self):
self.update_production_order(None)
self.update_work_order(None)
self.update_task_and_project()
def on_submit(self):
self.validate_mandatory_fields()
self.update_production_order(self.name)
self.update_work_order(self.name)
self.update_task_and_project()
def validate_mandatory_fields(self):
if self.production_order:
production_order = frappe.get_doc("Production Order", self.production_order)
pending_qty = flt(production_order.qty) - flt(production_order.produced_qty)
if self.work_order:
work_order = frappe.get_doc("Work Order", self.work_order)
pending_qty = flt(work_order.qty) - flt(work_order.produced_qty)
for data in self.time_logs:
if not data.from_time and not data.to_time:
@@ -120,16 +120,16 @@ class Timesheet(Document):
if flt(data.hours) == 0.0:
frappe.throw(_("Row {0}: Hours value must be greater than zero.").format(data.idx))
if self.production_order and flt(data.completed_qty) == 0:
if self.work_order and flt(data.completed_qty) == 0:
frappe.throw(_("Row {0}: Completed Qty must be greater than zero.").format(data.idx))
if self.production_order and flt(pending_qty) < flt(data.completed_qty) and flt(pending_qty) > 0:
if self.work_order and flt(pending_qty) < flt(data.completed_qty) and flt(pending_qty) > 0:
frappe.throw(_("Row {0}: Completed Qty cannot be more than {1} for operation {2}").format(data.idx, pending_qty, data.operation),
OverProductionLoggedError)
OverWorkLoggedError)
def update_production_order(self, time_sheet):
if self.production_order:
pro = frappe.get_doc('Production Order', self.production_order)
def update_work_order(self, time_sheet):
if self.work_order:
pro = frappe.get_doc('Work Order', self.work_order)
for timesheet in self.time_logs:
for data in pro.operations:
@@ -152,8 +152,8 @@ class Timesheet(Document):
return frappe.db.sql("""select
sum(tsd.hours*60) as mins, sum(tsd.completed_qty) as completed_qty, min(tsd.from_time) as from_time,
max(tsd.to_time) as to_time from `tabTimesheet Detail` as tsd, `tabTimesheet` as ts where
ts.production_order = %s and tsd.operation_id = %s and ts.docstatus=1 and ts.name = tsd.parent""",
(self.production_order, operation_id), as_dict=1)[0]
ts.work_order = %s and tsd.operation_id = %s and ts.docstatus=1 and ts.name = tsd.parent""",
(self.work_order, operation_id), as_dict=1)[0]
def update_task_and_project(self):
tasks, projects = [], []
@@ -181,7 +181,7 @@ class Timesheet(Document):
def validate_overlap(self, data):
settings = frappe.get_single('Projects Settings')
if self.production_order:
if self.work_order:
self.validate_overlap_for("workstation", data, data.workstation, settings.ignore_workstation_time_overlap)
else:
self.validate_overlap_for("user", data, self.user, settings.ignore_user_time_overlap)
@@ -232,7 +232,7 @@ class Timesheet(Document):
if args.workstation and args.from_time and args.to_time:
check_if_within_operating_hours(args.workstation, args.operation, args.from_time, args.to_time)
def schedule_for_production_order(self, index):
def schedule_for_work_order(self, index):
for data in self.time_logs:
if data.idx == index:
self.move_to_next_day(data) #check for workstation holiday

View File

@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
@@ -11,6 +12,7 @@
"editable_grid": 1,
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -21,7 +23,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Activity Type",
"length": 0,
"no_copy": 0,
@@ -38,6 +42,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -48,7 +53,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "From Time",
"length": 0,
"no_copy": 0,
@@ -65,6 +72,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -75,7 +83,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -91,6 +101,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -101,7 +112,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Hrs",
"length": 0,
"no_copy": 0,
@@ -117,6 +130,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -127,7 +141,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "To Time",
"length": 0,
"no_copy": 0,
@@ -144,6 +160,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -154,7 +171,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -170,18 +189,21 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:parent.production_order",
"depends_on": "eval:parent.work_order",
"fieldname": "completed_qty",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Completed Qty",
"length": 0,
"no_copy": 0,
@@ -198,18 +220,21 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:parent.production_order",
"depends_on": "eval:parent.work_order",
"fieldname": "workstation",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Workstation",
"length": 0,
"no_copy": 0,
@@ -227,6 +252,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -237,7 +263,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -253,18 +281,21 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:parent.production_order",
"depends_on": "eval:parent.work_order",
"fieldname": "operation",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Operation",
"length": 0,
"no_copy": 0,
@@ -282,18 +313,21 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:parent.production_order",
"depends_on": "eval:parent.work_order",
"fieldname": "operation_id",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Operation Id",
"length": 0,
"no_copy": 0,
@@ -310,6 +344,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -320,7 +355,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -336,6 +373,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -346,7 +384,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Project",
"length": 0,
"no_copy": 0,
@@ -364,6 +404,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -374,7 +415,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -390,6 +433,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -401,7 +445,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Task",
"length": 0,
"no_copy": 0,
@@ -419,6 +465,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -429,7 +476,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -445,6 +494,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -456,7 +506,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Bill",
"length": 0,
"no_copy": 0,
@@ -473,6 +525,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -483,7 +536,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -499,6 +554,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -510,7 +566,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Billing Hours",
"length": 0,
"no_copy": 0,
@@ -527,6 +585,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -538,7 +597,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -554,6 +615,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -565,7 +627,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Billing Rate",
"length": 0,
"no_copy": 0,
@@ -582,6 +646,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -595,7 +660,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Billing Amount",
"length": 0,
"no_copy": 0,
@@ -612,6 +679,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -622,7 +690,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -638,6 +708,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -648,7 +719,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Costing Rate",
"length": 0,
"no_copy": 0,
@@ -665,6 +738,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -677,7 +751,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Costing Amount",
"length": 0,
"no_copy": 0,
@@ -694,6 +770,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -704,7 +781,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Reference",
"length": 0,
"no_copy": 0,
@@ -721,6 +800,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -731,7 +811,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sales Invoice",
"length": 0,
"no_copy": 1,
@@ -749,17 +831,17 @@
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-11-03 16:01:10.519549",
"modified": "2018-01-07 11:46:04.045313",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet Detail",
@@ -768,6 +850,8 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_order": "ASC",
"track_changes": 0,
"track_seen": 0
}