test case fix for Time Log

This commit is contained in:
Neil Trini Lasrado 2015-04-16 11:25:34 +05:30
parent 50a0fd6204
commit da8c6f6ae2
2 changed files with 21 additions and 13 deletions

View File

@ -88,6 +88,17 @@ class TestTimeLog(unittest.TestCase):
def test_total_activity_cost_for_project(self):
frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
frappe.db.sql("""delete from `tabActivity Cost` where employee = "_T-Employee-0001" and activity_type = "_Test Activity Type" """)
activity_cost = frappe.new_doc('Activity Cost')
activity_cost.update({
"employee": "_T-Employee-0001",
"employee_name": "_Test Employee",
"activity_type": "_Test Activity Type",
"billing_rate": 100,
"costing_rate": 50
})
activity_cost.insert()
frappe.get_doc({
"project_name": "_Test Project 1",

View File

@ -28,15 +28,11 @@ class TimeLog(Document):
self.validate_cost()
def on_submit(self):
if self.for_manufacturing:
self.update_production_order()
if self.task:
self.update_task()
def on_cancel(self):
if self.for_manufacturing:
self.update_production_order()
if self.task:
self.update_task()
def before_update_after_submit(self):
@ -133,7 +129,7 @@ class TimeLog(Document):
def update_production_order(self):
"""Updates `start_date`, `end_date`, `status` for operation in Production Order."""
if self.production_order:
if self.production_order and self.for_manufacturing:
if not self.operation_id:
frappe.throw(_("Operation ID not set"))
@ -231,6 +227,7 @@ class TimeLog(Document):
frappe.throw(_("Task is Mandatory if Time Log is against a project"))
def update_task(self):
if self.task and frappe.db.exists("Task", self.task):
task = frappe.get_doc("Task", self.task)
task.update_time_and_costing()
task.save()