mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
test case fix for Time Log
This commit is contained in:
@@ -88,6 +88,17 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
def test_total_activity_cost_for_project(self):
|
def test_total_activity_cost_for_project(self):
|
||||||
frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
|
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 `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({
|
frappe.get_doc({
|
||||||
"project_name": "_Test Project 1",
|
"project_name": "_Test Project 1",
|
||||||
|
|||||||
@@ -28,16 +28,12 @@ class TimeLog(Document):
|
|||||||
self.validate_cost()
|
self.validate_cost()
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if self.for_manufacturing:
|
self.update_production_order()
|
||||||
self.update_production_order()
|
self.update_task()
|
||||||
if self.task:
|
|
||||||
self.update_task()
|
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
if self.for_manufacturing:
|
self.update_production_order()
|
||||||
self.update_production_order()
|
self.update_task()
|
||||||
if self.task:
|
|
||||||
self.update_task()
|
|
||||||
|
|
||||||
def before_update_after_submit(self):
|
def before_update_after_submit(self):
|
||||||
self.set_status()
|
self.set_status()
|
||||||
@@ -133,7 +129,7 @@ class TimeLog(Document):
|
|||||||
def update_production_order(self):
|
def update_production_order(self):
|
||||||
"""Updates `start_date`, `end_date`, `status` for operation in Production Order."""
|
"""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:
|
if not self.operation_id:
|
||||||
frappe.throw(_("Operation ID not set"))
|
frappe.throw(_("Operation ID not set"))
|
||||||
|
|
||||||
@@ -231,9 +227,10 @@ class TimeLog(Document):
|
|||||||
frappe.throw(_("Task is Mandatory if Time Log is against a project"))
|
frappe.throw(_("Task is Mandatory if Time Log is against a project"))
|
||||||
|
|
||||||
def update_task(self):
|
def update_task(self):
|
||||||
task = frappe.get_doc("Task", self.task)
|
if self.task and frappe.db.exists("Task", self.task):
|
||||||
task.update_time_and_costing()
|
task = frappe.get_doc("Task", self.task)
|
||||||
task.save()
|
task.update_time_and_costing()
|
||||||
|
task.save()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start, end, filters=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user