Skip to content

Commit ecf77c7

Browse files
committed
[IMP] testing.py: track the test class
Will be use by the upgrade platform to allow IntegrityTest during production upgrades. closes #327 Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
1 parent 1b727a8 commit ecf77c7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/testing.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,22 @@ def key(self):
224224
def _set_value(self, key, value):
225225
self._init_db()
226226
value = json.dumps(value, sort_keys=True)
227+
klass = None
228+
for mro in type(self).mro():
229+
if mro.__module__ in ("odoo.upgrade.testing", "odoo.addons.base.maintenance.migrations.testing"):
230+
klass = mro.__name__
231+
break
232+
227233
cr = self._data_table_cr
228234
query = util.format_query(
229235
cr,
230236
"""
231-
INSERT INTO {} (key, value) VALUES (%s, %s)
232-
ON CONFLICT (key) DO UPDATE SET value=EXCLUDED.value
237+
INSERT INTO {} (key, class, value) VALUES (%s, %s, %s)
238+
ON CONFLICT (key) DO UPDATE SET value=EXCLUDED.value, class=EXCLUDED.class
233239
""",
234240
DATA_TABLE,
235241
)
236-
cr.execute(query, (key, value))
242+
cr.execute(query, (key, klass, value))
237243
cr._cnx.commit()
238244

239245
def _get_value(self, key):
@@ -264,13 +270,17 @@ def _init_db(self):
264270
"""
265271
CREATE TABLE {} (
266272
key VARCHAR(255) PRIMARY KEY,
273+
class varchar,
267274
value JSONB NOT NULL
268275
)
269276
""",
270277
DATA_TABLE,
271278
)
272279
cr.execute(query)
273-
cr._cnx.commit()
280+
else:
281+
# upgrade existing table
282+
util.create_column(cr, DATA_TABLE, "class", "varchar")
283+
cr._cnx.commit()
274284
UpgradeCommon.__initialized = True
275285

276286
def _setup_registry(self):

0 commit comments

Comments
 (0)