[fix] Time Log overlap validation and test cases
This commit is contained in:
parent
f34e63123f
commit
94a1f3eb90
@ -21,6 +21,22 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertRaises(OverlapError, tl2.insert)
|
self.assertRaises(OverlapError, tl2.insert)
|
||||||
|
|
||||||
|
tl3 = make_time_log_test_record(user= "test@example.com", employee= "_T-Employee-0002",
|
||||||
|
from_time= tl1.from_time - datetime.timedelta(hours=1),
|
||||||
|
to_time= tl1.to_time + datetime.timedelta(hours=1), do_not_save= 1)
|
||||||
|
|
||||||
|
self.assertRaises(OverlapError, tl3.insert)
|
||||||
|
|
||||||
|
tl4 = make_time_log_test_record(user= "test@example.com", employee= "_T-Employee-0002",
|
||||||
|
from_time= tl1.from_time + datetime.timedelta(minutes=20),
|
||||||
|
to_time= tl1.to_time + datetime.timedelta(minutes=30), do_not_save= 1)
|
||||||
|
|
||||||
|
self.assertRaises(OverlapError, tl4.insert)
|
||||||
|
|
||||||
|
make_time_log_test_record(user= "test@example.com", employee= "_T-Employee-0002",
|
||||||
|
from_time= tl1.to_time,
|
||||||
|
to_time= tl1.to_time + datetime.timedelta(hours=1))
|
||||||
|
|
||||||
def test_production_order_status(self):
|
def test_production_order_status(self):
|
||||||
prod_order = make_prod_order_test_record(item= "_Test FG Item 2", qty= 1, do_not_submit= True)
|
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.set_production_order_operations()
|
||||||
|
|||||||
@ -88,8 +88,8 @@ class TimeLog(Document):
|
|||||||
existing = frappe.db.sql("""select name, from_time, to_time from `tabTime Log`
|
existing = frappe.db.sql("""select name, from_time, to_time from `tabTime Log`
|
||||||
where `{0}`=%(val)s and
|
where `{0}`=%(val)s and
|
||||||
(
|
(
|
||||||
(%(from_time)s between from_time and to_time) or
|
(%(from_time)s > from_time and %(from_time)s < to_time) or
|
||||||
(%(to_time)s between from_time and to_time) or
|
(%(to_time)s > from_time and %(to_time)s < to_time) or
|
||||||
(%(from_time)s <= from_time and %(to_time)s >= to_time))
|
(%(from_time)s <= from_time and %(to_time)s >= to_time))
|
||||||
and name!=%(name)s
|
and name!=%(name)s
|
||||||
and docstatus < 2""".format(fieldname),
|
and docstatus < 2""".format(fieldname),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user