[FIX] mrp: consider timezone in test
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, time
|
||||
|
||||
from odoo.addons.mrp.tests.common import TestMrpCommon
|
||||
from odoo.addons.resource.models.resource import to_naive_utc
|
||||
|
||||
|
||||
class TestOee(TestMrpCommon):
|
||||
@@ -23,22 +24,33 @@ class TestOee(TestMrpCommon):
|
||||
if day.weekday() in (5, 6):
|
||||
day -= timedelta(days=2)
|
||||
|
||||
def time_to_string_utc_datetime(time):
|
||||
return str(to_naive_utc(datetime.combine(day, time), self.workcenter_1.resource_id))
|
||||
|
||||
start_time = time_to_string_utc_datetime(time(10, 43, 22))
|
||||
end_time = time_to_string_utc_datetime(time(10, 56, 22))
|
||||
# Productive time duration (13 min)
|
||||
self.create_productivity_line(self.env.ref('mrp.block_reason7'), str(day) + " " + "10:43:22", str(day) + " " + "10:56:22")
|
||||
self.create_productivity_line(self.env.ref('mrp.block_reason7'), start_time, end_time)
|
||||
|
||||
# Material Availability time duration (1.52 min)
|
||||
# Check working state is blocked or not.
|
||||
workcenter_productivity_1 = self.create_productivity_line(self.env.ref('mrp.block_reason0'), str(day) + " " + "10:47:08")
|
||||
start_time = time_to_string_utc_datetime(time(10, 47, 8))
|
||||
workcenter_productivity_1 = self.create_productivity_line(self.env.ref('mrp.block_reason0'), start_time)
|
||||
self.assertEqual(self.workcenter_1.working_state, 'blocked', "Wrong working state of workcenter.")
|
||||
|
||||
# Check working state is normal or not.
|
||||
workcenter_productivity_1.write({'date_end': str(day) + " " + "10:48:39"})
|
||||
end_time = time_to_string_utc_datetime(time(10, 48, 39))
|
||||
workcenter_productivity_1.write({'date_end': end_time})
|
||||
self.assertEqual(self.workcenter_1.working_state, 'normal', "Wrong working state of workcenter.")
|
||||
|
||||
# Process Defect time duration (1.33 min)
|
||||
self.create_productivity_line(self.env.ref('mrp.block_reason5'), str(day) + " " + "10:48:38", str(day) + " " + "10:49:58")
|
||||
start_time = time_to_string_utc_datetime(time(10, 48, 38))
|
||||
end_time = time_to_string_utc_datetime(time(10, 49, 58))
|
||||
self.create_productivity_line(self.env.ref('mrp.block_reason5'), start_time, end_time)
|
||||
# Reduced Speed time duration (3.0 min)
|
||||
self.create_productivity_line(self.env.ref('mrp.block_reason4'), str(day) + " " + "10:50:22", str(day) + " " + "10:53:22")
|
||||
start_time = time_to_string_utc_datetime(time(10, 50, 22))
|
||||
end_time = time_to_string_utc_datetime(time(10, 53, 22))
|
||||
self.create_productivity_line(self.env.ref('mrp.block_reason4'), start_time, end_time)
|
||||
|
||||
# Block time : ( Process Defact (1.33 min) + Reduced Speed (3.0 min) + Material Availability (1.52 min)) = 5.85 min
|
||||
blocked_time_in_hour = round(((1.33 + 3.0 + 1.52) / 60.0), 2)
|
||||
|
||||
Reference in New Issue
Block a user