Merge pull request #3003 from neilLasrado/activity-type

time_log_for select field in TL changed to against_manufacturing (check)
This commit is contained in:
Nabin Hait 2015-03-24 18:03:25 +05:30
commit 37eaa0cca3
13 changed files with 46 additions and 85 deletions

View File

@ -373,7 +373,7 @@ def get_events(start, end, filters=None):
@frappe.whitelist()
def make_time_log(name, operation, from_time, to_time, qty=None, project=None, workstation=None, operation_id=None):
time_log = frappe.new_doc("Time Log")
time_log.time_log_for = 'Manufacturing'
time_log.for_manufacturing = 1
time_log.from_time = from_time
time_log.to_time = to_time
time_log.production_order = name

View File

@ -18,7 +18,7 @@
{
"allow_on_submit": 0,
"fieldname": "operation",
"fieldtype": "Text",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
@ -27,7 +27,7 @@
"no_copy": 0,
"oldfieldname": "operation_no",
"oldfieldtype": "Data",
"options": "",
"options": "Operation",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -292,7 +292,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-02-24 00:27:44.651084",
"modified": "2015-03-24 07:02:54.203235",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order Operation",

View File

@ -116,7 +116,6 @@ erpnext.patches.v5_0.rename_total_fields
erpnext.patches.v5_0.new_crm_module
erpnext.patches.v5_0.rename_customer_issue
erpnext.patches.v5_0.update_material_transfer_for_manufacture
erpnext.patches.v5_0.manufacturing_activity_type
erpnext.patches.v5_0.update_item_description_and_image
erpnext.patches.v5_0.update_material_transferred_for_manufacturing
erpnext.patches.v5_0.stock_entry_update_value

View File

@ -1,11 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
if not frappe.db.exists('Activity Type','Manufacturing') and frappe.get_all("Company"):
frappe.get_doc({
"doctype": "Activity Type",
"activity_type": "Manufacturing"
}).insert()

View File

@ -2,18 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
class ActivityType(Document):
def on_trash(self):
self.validate_manufacturing_type()
def before_rename(self, olddn, newdn, merge=False):
self.validate_manufacturing_type()
def validate_manufacturing_type(self):
if self.activity_type == 'Manufacturing':
frappe.throw(_("Activity Type 'Manufacturing' cannot be deleted/renamed."))
pass

View File

@ -6,7 +6,6 @@
"from_time": "2013-01-01 10:00:00.000000",
"note": "_Test Note",
"to_time": "2013-01-01 11:00:00.000000",
"time_log_for": "Project",
"project": "_Test Project"
}
]

View File

@ -36,7 +36,7 @@ class TestTimeLog(unittest.TestCase):
time_log = frappe.get_doc({
"doctype": "Time Log",
"time_log_for": "Manufacturing",
"for_manufacturing": 1,
"production_order": prod_order.name,
"qty": 1,
"from_time": "2014-12-26 00:00:00",
@ -54,7 +54,7 @@ class TestTimeLog(unittest.TestCase):
time_log = frappe.get_doc({
"doctype": "Time Log",
"time_log_for": "Manufacturing",
"for_manufacturing": 1,
"production_order": prod_order.name,
"operation": prod_order.operations[0].operation,
"operation_id": prod_order.operations[0].name,

View File

@ -5,7 +5,7 @@ frappe.provide("erpnext.projects");
frappe.ui.form.on("Time Log", "onload", function(frm) {
frm.set_query("task", erpnext.queries.task);
if (frm.doc.time_log_for == "Manufacturing") {
if (frm.doc.for_manufacturing) {
frappe.ui.form.trigger("Time Log", "production_order");
}
});
@ -60,7 +60,7 @@ $.extend(cur_frm.cscript, {
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] = (i+1) +". "+ row.operation;
operations[i] = row.operation;
});
frappe.meta.get_docfield("Time Log", "operation", me.frm.doc.name).options = "\n" + operations.join("\n");
refresh_field("operation");
@ -81,11 +81,5 @@ $.extend(cur_frm.cscript, {
}
}
});
},
time_log_for: function(doc) {
if (doc.time_log_for == 'Manufacturing') {
cur_frm.set_value("activity_type", "Manufacturing")
}
}
});

View File

@ -42,14 +42,6 @@
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "billable",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Billable",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "user",
"fieldtype": "Link",
@ -75,18 +67,23 @@
"reqd": 0
},
{
"default": "Project",
"fieldname": "time_log_for",
"fieldtype": "Select",
"label": "Time Log For",
"options": "Project\nManufacturing",
"fieldname": "billable",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Billable",
"permlevel": 0,
"precision": "",
"read_only": 1,
"reqd": 0
"read_only": 0
},
{
"depends_on": "",
"fieldname": "for_manufacturing",
"fieldtype": "Check",
"label": "For Manufacturing",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"depends_on": "eval:!doc.for_manufacturing",
"fieldname": "activity_type",
"fieldtype": "Link",
"in_list_view": 0,
@ -94,10 +91,10 @@
"options": "Activity Type",
"permlevel": 0,
"read_only": 0,
"reqd": 1
"reqd": 0
},
{
"depends_on": "eval:doc.time_log_for != 'Manufacturing'",
"depends_on": "eval:!doc.for_manufacturing",
"fieldname": "task",
"fieldtype": "Link",
"label": "Task",
@ -106,33 +103,34 @@
"read_only": 0
},
{
"depends_on": "eval:doc.time_log_for == 'Manufacturing'",
"depends_on": "eval:doc.for_manufacturing",
"fieldname": "section_break_11",
"fieldtype": "Section Break",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "eval:doc.time_log_for == 'Manufacturing'",
"depends_on": "",
"fieldname": "production_order",
"fieldtype": "Link",
"label": "Production Order",
"options": "Production Order",
"permlevel": 0,
"precision": "",
"read_only": 1
"read_only": 0
},
{
"depends_on": "eval:doc.time_log_for == 'Manufacturing'",
"depends_on": "",
"fieldname": "operation",
"fieldtype": "Select",
"fieldtype": "Link",
"label": "Operation",
"options": "",
"options": "Operation",
"permlevel": 0,
"precision": "",
"read_only": 1
"read_only": 0
},
{
"depends_on": "",
"fieldname": "operation_id",
"fieldtype": "Data",
"hidden": 1,
@ -150,17 +148,17 @@
"precision": ""
},
{
"depends_on": "eval:doc.time_log_for == 'Manufacturing'",
"depends_on": "",
"fieldname": "workstation",
"fieldtype": "Link",
"label": "Workstation",
"options": "Workstation",
"permlevel": 0,
"precision": "",
"read_only": 1
"read_only": 0
},
{
"depends_on": "eval:doc.time_log_for == 'Manufacturing'",
"depends_on": "",
"description": "Operation completed for how many finished goods?",
"fieldname": "completed_qty",
"fieldtype": "Float",
@ -188,7 +186,7 @@
"read_only": 0
},
{
"depends_on": "eval:doc.time_log_for",
"depends_on": "",
"fieldname": "project",
"fieldtype": "Link",
"in_list_view": 1,
@ -244,7 +242,7 @@
"icon": "icon-time",
"idx": 1,
"is_submittable": 1,
"modified": "2015-03-10 17:07:35.506886",
"modified": "2015-03-24 08:10:31.412670",
"modified_by": "Administrator",
"module": "Projects",
"name": "Time Log",

View File

@ -23,7 +23,6 @@ class TimeLog(Document):
self.validate_time_log_for()
self.check_workstation_timings()
self.validate_production_order()
self.validate_project()
self.validate_manufacturing()
def on_submit(self):
@ -104,9 +103,11 @@ class TimeLog(Document):
self.hours = flt(time_diff_in_seconds(self.to_time, self.from_time)) / 3600
def validate_time_log_for(self):
if self.time_log_for == "Project":
if not self.for_manufacturing:
for fld in ["production_order", "operation", "workstation", "completed_qty"]:
self.set(fld, None)
else:
self.activity_type=None
def check_workstation_timings(self):
"""Checks if **Time Log** is between operating hours of the **Workstation**."""
@ -123,7 +124,7 @@ class TimeLog(Document):
def update_production_order(self):
"""Updates `start_date`, `end_date`, `status` for operation in Production Order."""
if self.time_log_for=="Manufacturing" and self.production_order:
if self.for_manufacturing and self.production_order:
if not self.operation_id:
frappe.throw(_("Operation ID not set"))
@ -185,15 +186,8 @@ class TimeLog(Document):
where production_order = %s and operation_id = %s and docstatus=1""",
(self.production_order, self.operation_id), as_dict=1)[0]
def validate_project(self):
if self.time_log_for == 'Project':
if not self.project:
frappe.throw(_("Project is Mandatory."))
if self.time_log_for == "":
self.project = None
def validate_manufacturing(self):
if self.time_log_for == 'Manufacturing':
if self.for_manufacturing:
if not self.production_order:
frappe.throw(_("Production Order is Mandatory"))
if not self.operation:

View File

@ -3,7 +3,7 @@
// render
frappe.listview_settings['Time Log'] = {
add_fields: ["status", "billable", "activity_type", "task", "project", "hours", "time_log_for"],
add_fields: ["status", "billable", "activity_type", "task", "project", "hours", "for_manufacturing"],
selectable: true,
onload: function(me) {
me.page.add_menu_item(__("Make Time Log Batch"), function() {

View File

@ -35,7 +35,7 @@ def create_time_log():
"from_time": "2013-01-02 10:00:00.000000",
"to_time": "2013-01-02 11:00:00.000000",
"docstatus": 0,
"time_log_for": "Project"
"for_manufacturing": 0
})
time_log.insert()
time_log.submit()

View File

@ -135,7 +135,6 @@ def install(country=None):
{'doctype': 'Activity Type', 'activity_type': _('Proposal Writing')},
{'doctype': 'Activity Type', 'activity_type': _('Execution')},
{'doctype': 'Activity Type', 'activity_type': _('Communication')},
{'doctype': 'Activity Type', 'activity_type': 'Manufacturing'},
{'doctype': "Item Attribute", "attribute_name": _("Size"), "item_attribute_values": [
{"attribute_value": _("Extra Small"), "abbr": "XS"},
@ -158,7 +157,7 @@ def install(country=None):
{'doctype': "Email Account", "email_id": "jobs@example.com", "append_to": "Job Applicant"}
]
from erpnext.setup.page.setup_wizard.fixtures import industry_type, operations
from erpnext.setup.page.setup_wizard.fixtures import industry_type
records += [{"doctype":"Industry Type", "industry": d} for d in industry_type.items]
# records += [{"doctype":"Operation", "operation": d} for d in operations.items]