mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-25 04:53:01 +00:00
Test case fixes
This commit is contained in:
@@ -8,11 +8,11 @@ import unittest
|
||||
|
||||
from erpnext.projects.doctype.time_log.time_log import OverlapError
|
||||
from erpnext.projects.doctype.time_log.time_log import NotSubmittedError
|
||||
|
||||
from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError
|
||||
from erpnext.manufacturing.doctype.workstation.workstation import NotInWorkingHoursError
|
||||
|
||||
from erpnext.projects.doctype.time_log_batch.test_time_log_batch import *
|
||||
from erpnext.manufacturing.doctype.production_order.test_production_order import make_prod_order_test_record
|
||||
|
||||
|
||||
class TestTimeLog(unittest.TestCase):
|
||||
def test_duplication(self):
|
||||
@@ -30,8 +30,8 @@ class TestTimeLog(unittest.TestCase):
|
||||
frappe.db.sql("delete from `tabTime Log`")
|
||||
|
||||
def test_production_order_status(self):
|
||||
prod_order = make_prod_order(self)
|
||||
|
||||
prod_order = make_prod_order_test_record(item="_Test FG Item 2", qty=1, do_not_submit=True)
|
||||
prod_order.set_production_order_operations()
|
||||
prod_order.save()
|
||||
|
||||
time_log = frappe.get_doc({
|
||||
@@ -46,7 +46,8 @@ class TestTimeLog(unittest.TestCase):
|
||||
self.assertRaises(NotSubmittedError, time_log.save)
|
||||
|
||||
def test_time_log_on_holiday(self):
|
||||
prod_order = make_prod_order(self)
|
||||
prod_order = make_prod_order_test_record(item="_Test FG Item 2", qty=1,
|
||||
planned_start_date="2014-11-25 00:00:00", do_not_save=True)
|
||||
prod_order.set_production_order_operations()
|
||||
prod_order.save()
|
||||
prod_order.submit()
|
||||
@@ -85,16 +86,5 @@ class TestTimeLog(unittest.TestCase):
|
||||
self.assertRaises(frappe.ValidationError, test_time_log.save)
|
||||
frappe.db.sql("delete from `tabTime Log`")
|
||||
|
||||
def make_prod_order(self):
|
||||
return frappe.get_doc({
|
||||
"doctype":"Production Order",
|
||||
"production_item": "_Test FG Item 2",
|
||||
"bom_no": "BOM/_Test FG Item 2/001",
|
||||
"qty": 1,
|
||||
"wip_warehouse": "_Test Warehouse - _TC",
|
||||
"fg_warehouse": "_Test Warehouse 1 - _TC",
|
||||
"company": "_Test Company"
|
||||
})
|
||||
|
||||
test_records = frappe.get_test_records('Time Log')
|
||||
test_ignore = ["Time Log Batch", "Sales Invoice"]
|
||||
|
||||
@@ -96,12 +96,13 @@ class TimeLog(Document):
|
||||
return existing[0] if existing else None
|
||||
|
||||
def validate_timings(self):
|
||||
if get_datetime(self.to_time) < get_datetime(self.from_time):
|
||||
if self.to_time and self.from_time and get_datetime(self.to_time) < get_datetime(self.from_time):
|
||||
frappe.throw(_("From Time cannot be greater than To Time"))
|
||||
|
||||
def calculate_total_hours(self):
|
||||
from frappe.utils import time_diff_in_seconds
|
||||
self.hours = flt(time_diff_in_seconds(self.to_time, self.from_time)) / 3600
|
||||
if self.to_time and self.from_time:
|
||||
from frappe.utils import time_diff_in_seconds
|
||||
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":
|
||||
@@ -110,7 +111,7 @@ class TimeLog(Document):
|
||||
|
||||
def check_workstation_timings(self):
|
||||
"""Checks if **Time Log** is between operating hours of the **Workstation**."""
|
||||
if self.workstation:
|
||||
if self.workstation and self.from_time and self.to_time:
|
||||
from erpnext.manufacturing.doctype.workstation.workstation import check_if_within_operating_hours
|
||||
check_if_within_operating_hours(self.workstation, self.operation, self.from_time, self.to_time)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user