diff options
| author | Raphael Collet <rco@odoo.com> | 2019-08-23 09:23:39 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2019-08-23 10:13:19 +0000 |
| commit | fdba00ebb8541407c2a43d19b66b463fcba15e2d (patch) | |
| tree | 33e1486d83b773d199d306ba28e92cd034b5de0f /odoo/addons/test_new_api/tests/test_new_fields.py | |
| parent | e388efd05941d50874c9f7ac1ca1226a4497e9f2 (diff) | |
[FIX] models: check constraints on computed stored fields
closes odoo/odoo#36008
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/addons/test_new_api/tests/test_new_fields.py')
| -rw-r--r-- | odoo/addons/test_new_api/tests/test_new_fields.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index 9b17933397a..e65b20ed561 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -8,7 +8,7 @@ from PIL import Image import psycopg2 from odoo import fields -from odoo.exceptions import AccessError, UserError +from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tests import common from odoo.tools import mute_logger, float_repr from odoo.tools.date_utils import add, subtract, start_of, end_of @@ -439,7 +439,7 @@ class TestFields(common.TransactionCase): # remove oneself from discussion participants: we can no longer create # messages in discussion discussion.participants -= self.env.user - with self.assertRaises(Exception): + with self.assertRaises(ValidationError): self.env['test_new_api.message'].create({'discussion': discussion.id, 'body': 'Whatever'}) # make sure that assertRaises() does not leave fields to recompute @@ -450,6 +450,12 @@ class TestFields(common.TransactionCase): discussion.participants += self.env.user self.env['test_new_api.message'].create({'discussion': discussion.id, 'body': 'Whatever'}) + # check constraint on recomputed field + self.assertTrue(discussion.messages) + with self.assertRaises(ValidationError): + discussion.name = "X" + discussion.flush() + def test_20_float(self): """ test rounding of float fields """ record = self.env['test_new_api.mixed'].create({}) |
