From b16c6f36e34d388917aaebb98f351b568ca09936 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Sun, 6 Dec 2020 12:23:12 +0100 Subject: [PATCH] [IMP] Create records with timestamp; [RFR] No /migration/ level when using upgrade-path --- upgrade_analysis/models/upgrade_analysis.py | 3 ++- upgrade_analysis/upgrade_log.py | 10 ++++++---- .../wizards/upgrade_generate_record_wizard.py | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/upgrade_analysis/models/upgrade_analysis.py b/upgrade_analysis/models/upgrade_analysis.py index 52eff5d85..39320ba0f 100644 --- a/upgrade_analysis/models/upgrade_analysis.py +++ b/upgrade_analysis/models/upgrade_analysis.py @@ -62,11 +62,12 @@ class UpgradeAnalysis(models.Model): % module_name ) module_path = os.path.join(self.upgrade_path, module_name) + full_path = os.path.join(module_path, version) else: module_path = get_module_path(module_name) + full_path = os.path.join(module_path, "migrations", version) if not module_path: return "ERROR: could not find module path of '%s':\n" % (module_name) - full_path = os.path.join(module_path, "migrations", version) if not os.path.exists(full_path): try: os.makedirs(full_path) diff --git a/upgrade_analysis/upgrade_log.py b/upgrade_analysis/upgrade_log.py index 10c28596b..345b1d772 100644 --- a/upgrade_analysis/upgrade_log.py +++ b/upgrade_analysis/upgrade_log.py @@ -27,8 +27,8 @@ def get_record_id(cr, module, model, field, mode): return record[0] cr.execute( "INSERT INTO upgrade_record " - "(module, model, field, mode, type) " - "VALUES (%s, %s, %s, %s, %s)", + "(create_date, module, model, field, mode, type) " + "VALUES (NOW() AT TIME ZONE 'UTC', %s, %s, %s, %s, %s)", (module, model, field, mode, "field"), ) cr.execute( @@ -67,7 +67,8 @@ def compare_registries(cr, module, registry, local_registry): if not cr.fetchone(): cr.execute( "INSERT INTO upgrade_attribute " - "(name, value, record_id) VALUES (%s, %s, %s)", + "(create_date, name, value, record_id) " + "VALUES (NOW() AT TIME ZONE 'UTC', %s, %s, %s)", (key, value, record_id), ) old_field[key] = value @@ -212,6 +213,7 @@ def log_xml_id(cr, module, xml_id): if not cr.fetchone(): cr.execute( "INSERT INTO upgrade_record " - "(module, model, name, type) values(%s, %s, %s, %s)", + "(create_date, module, model, name, type) " + "values(NOW() AT TIME ZONE 'UTC', %s, %s, %s, %s)", (module, record[0], xml_id, "xmlid"), ) diff --git a/upgrade_analysis/wizards/upgrade_generate_record_wizard.py b/upgrade_analysis/wizards/upgrade_generate_record_wizard.py index 84dd36622..ace540646 100644 --- a/upgrade_analysis/wizards/upgrade_generate_record_wizard.py +++ b/upgrade_analysis/wizards/upgrade_generate_record_wizard.py @@ -88,8 +88,9 @@ class GenerateWizard(models.TransientModel): # Log model records self.env.cr.execute( """INSERT INTO upgrade_record - (module, name, model, type) - SELECT imd2.module, imd2.module || '.' || imd.name AS name, + (create_date, module, name, model, type) + SELECT NOW() AT TIME ZONE 'UTC', + imd2.module, imd2.module || '.' || imd.name AS name, im.model, 'model' AS type FROM ( SELECT min(id) as id, name, res_id