Files
tryton/trytond/tests/test_field_function.py
T
Cédric Krier fc66c17eb0 Call getter function when accessing Function field
If the record is unsaved and the getter is based on on_change_with, we can call
the getter to compute the value.
This value must not be stored in the cache as it may change prior to saving.

issue4193
issue9263
review317291002
2020-05-03 14:34:44 +02:00

33 lines
901 B
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
from trytond.pool import Pool
from trytond.tests.test_tryton import activate_module, with_transaction
class FieldFunctionTestCase(unittest.TestCase):
"Test Field Function"
@classmethod
def setUpClass(cls):
activate_module('tests')
@with_transaction()
def test_accessor(self):
"Test accessing field on unsaved instance"
pool = Pool()
Model = pool.get('test.function.accessor')
Target = pool.get('test.function.accessor.target')
target = Target()
target.save()
record = Model()
record.target = target
self.assertEqual(record.function, target)
def suite():
return unittest.TestLoader().loadTestsFromTestCase(FieldFunctionTestCase)