Add history tests for reading One2Many with datetime_field
issue5269 review20671002
This commit is contained in:
@@ -11,6 +11,10 @@ class TestHistory(ModelSQL):
|
||||
_history = True
|
||||
value = fields.Integer('Value')
|
||||
lines = fields.One2Many('test.history.line', 'history', 'Lines')
|
||||
lines_at_stamp = fields.One2Many(
|
||||
'test.history.line', 'history', 'Lines at Stamp',
|
||||
datetime_field='stamp')
|
||||
stamp = fields.Timestamp('Stamp')
|
||||
|
||||
|
||||
class TestHistoryLine(ModelSQL):
|
||||
|
||||
@@ -382,6 +382,9 @@ class HistoryTestCase(unittest.TestCase):
|
||||
|
||||
first_stamp = line_b.create_date
|
||||
|
||||
history.stamp = first_stamp
|
||||
history.save()
|
||||
|
||||
transaction.cursor.commit()
|
||||
|
||||
with Transaction().start(DB_NAME, USER,
|
||||
@@ -405,6 +408,9 @@ class HistoryTestCase(unittest.TestCase):
|
||||
history = History(history_id)
|
||||
self.assertEqual(history.value, 2)
|
||||
self.assertEqual([l.name for l in history.lines], ['c'])
|
||||
self.assertEqual(history.stamp, first_stamp)
|
||||
self.assertEqual(
|
||||
[l.name for l in history.lines_at_stamp], ['a', 'b'])
|
||||
|
||||
with Transaction().set_context(_datetime=first_stamp):
|
||||
history = History(history_id)
|
||||
@@ -415,6 +421,9 @@ class HistoryTestCase(unittest.TestCase):
|
||||
history = History(history_id)
|
||||
self.assertEqual(history.value, 2)
|
||||
self.assertEqual([l.name for l in history.lines], ['c'])
|
||||
self.assertEqual(history.stamp, first_stamp)
|
||||
self.assertEqual(
|
||||
[l.name for l in history.lines_at_stamp], ['a', 'b'])
|
||||
|
||||
def test0080_search_cursor_max(self):
|
||||
'Test search with number of history entries at cursor.IN_MAX'
|
||||
|
||||
Reference in New Issue
Block a user