[FIX] base: avoid being stuck on a test

During the nightly, it looks like some test in
`TestAccountEarlyPaymentDiscount` will reload the registry, restarting
all base tests, including `.test_add_field_valid`

This test cannot be executed on an existing database without providing
a `-i` for a strange reason.

If this is not a real issue, this simple assertion will avoid to get
stuck while running this test on an existing database.

closes odoo/odoo#129491

X-original-commit: 4c6e05cbb43d08c544d9d558f80b67ccb786d482
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2023-07-25 08:19:08 +02:00
parent 81a38cb63f
commit 1c598d4b00
+5 -1
View File
@@ -6,7 +6,7 @@ from psycopg2 import IntegrityError, ProgrammingError
import odoo
from odoo.exceptions import UserError, ValidationError, AccessError
from odoo.tools import mute_logger
from odoo.tools import mute_logger, config
from odoo.tests import common
from odoo import Command
@@ -407,6 +407,10 @@ class TestCustomFields(common.TransactionCase):
This is to forbid users to override class attributes.
"""
# For a strange reason, drop constraint will remain stuck if executed without initiating base. (even on an existing database)
# small assertion to avoid getting stuck on this test in this case.
self.assertIn('base', config['init'], 'This test can only be executed while installing base')
field = self.create_field('x_foo')
# Drop the SQL constraint, to bypass it,
# as a user could do through a SQL shell or a `cr.execute` in a server action