summaryrefslogtreecommitdiff
path: root/odoo/addons/test_testing_utilities/tests/test_form_impl.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2019-02-13 12:16:49 +0000
committerXavier Morel <xmo@odoo.com>2019-02-15 10:54:44 +0000
commitbb7b121206ef9af8f7c365552500b1c51f96638e (patch)
treec13d245701ca7f458988dcd46bb447e70146e517 /odoo/addons/test_testing_utilities/tests/test_form_impl.py
parent84abddfe904273daaa3be744b974c8cce98c30fb (diff)
[FIX] core: various issues & deviations from client's behaviour in Form
* Form would entirely mis-interpret the server's response to some results: for unmodified o2m records the server sends a (4), which was un-interpreted by Form, leading to the o2m record being lost entirely (as it rebuilds the entire o2m on setting) * on record creation, every field (except id) is considered modified not just the fields set by default_get * Form diverged from actual client in that it would send (1, id, {}) for unmodified o2m records, actual client sends (4, id, False) * datetimes should be sent stringified * onchange should not be triggered when none of the modified fields is flagged as an onchange trigger * the default value for numerical fields is 0 not False * convert m2m onchange results to (6, False, ids) instead of (6, 0, ids) for ease of diffing with actual client's data There are still a few odd divergences in the actual invocation of onchange when attempted on an SO, but they look to be of low relevance / risk. Note: making integer fields "required" has pretty much no effect anymore. This is in line with (my understanding of) the client's behaviour, but required the alteration of test models as the specific test on required... was using an integer field. closes odoo/odoo#31064
Diffstat (limited to 'odoo/addons/test_testing_utilities/tests/test_form_impl.py')
-rw-r--r--odoo/addons/test_testing_utilities/tests/test_form_impl.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/odoo/addons/test_testing_utilities/tests/test_form_impl.py b/odoo/addons/test_testing_utilities/tests/test_form_impl.py
index e2f0d0d89d3..344ae62f4d2 100644
--- a/odoo/addons/test_testing_utilities/tests/test_form_impl.py
+++ b/odoo/addons/test_testing_utilities/tests/test_form_impl.py
@@ -24,7 +24,7 @@ class TestBasic(TransactionCase):
self.assertEqual(f.f3, 21)
self.assertEqual(f.f4, 42)
- f.f1 = 4
+ f.f1 = '4'
self.assertEqual(f.f2, 42)
self.assertEqual(f.f3, 21)
self.assertEqual(f.f4, 10)
@@ -36,7 +36,7 @@ class TestBasic(TransactionCase):
r = f.save()
self.assertEqual(
(r.f1, r.f2, r.f3, r.f4),
- (4, 8, 4, 2),
+ ('4', 8, 4, 2),
)
def test_required(self):
@@ -45,12 +45,12 @@ class TestBasic(TransactionCase):
with self.assertRaisesRegexp(AssertionError, 'f1 is a required field'):
f.save()
# set f1 and unset f2 => should work
- f.f1 = 1
+ f.f1 = '1'
f.f2 = False
r = f.save()
self.assertEqual(
(r.f1, r.f2, r.f3, r.f4),
- (1, 0, 0, 0)
+ ('1', 0, 0, 0)
)
def test_readonly(self):
@@ -61,7 +61,7 @@ class TestBasic(TransactionCase):
f = Form(self.env['test_testing_utilities.readonly'])
with self.assertRaises(AssertionError):
- f.f1 = 5
+ f.f1 = '5'
with self.assertRaises(AssertionError):
f.f2 = 42
@@ -70,7 +70,7 @@ class TestBasic(TransactionCase):
"""
f = Form(self.env['test_testing_utilities.a'], view='test_testing_utilities.non_normalized_attrs')
- f.f1 = 1
+ f.f1 = '1'
f.f2 = 987
self.assertEqual(f.f5, 987)
self.assertEqual(f.f6, 987)
@@ -86,7 +86,7 @@ class TestBasic(TransactionCase):
# not readonly yet, should work
f.f2 = 5
# make f2 readonly
- f.f1 = 63
+ f.f1 = '63'
f.f3 = 5
with self.assertRaises(AssertionError):
f.f2 = 6
@@ -101,9 +101,9 @@ class TestM2O(TransactionCase):
f = Form(self.env['test_testing_utilities.d'])
- self.assertEqual(
- f.f, a,
- "The default value for the m2o should be the first Sub record"
+ self.assertFalse(
+ f.f,
+ "The default value gets overridden by the onchange"
)
f.f2 = "B"
self.assertEqual(
@@ -271,6 +271,7 @@ class TestO2M(TransactionCase):
[get(s) for s in r.subs],
[("2", 2, 2), ("2", 2, 2)]
)
+ self.assertEqual(r.v, 5)
with Form(r, view='test_testing_utilities.o2m_parent') as f:
with f.subs.new() as sub:
@@ -286,6 +287,7 @@ class TestO2M(TransactionCase):
[get(s) for s in r.subs],
[("2", 2, 2), ("5", 5, 5), ("2", 2, 2)]
)
+ self.assertEqual(r.v, 10)
with Form(r, view='test_testing_utilities.o2m_parent') as f, \
f.subs.edit(index=0) as sub,\
@@ -439,12 +441,12 @@ class TestEdition(TransactionCase):
"""
def test_trivial(self):
r = self.env['test_testing_utilities.a'].create({
- 'f1': 5,
+ 'f1': '5',
})
with Form(r) as f:
self.assertEqual(f.id, r.id)
- self.assertEqual(f.f1, 5)
+ self.assertEqual(f.f1, '5')
self.assertEqual(f.f4, 8)
f.f2 = 5