summaryrefslogtreecommitdiff
path: root/odoo/addons
diff options
context:
space:
mode:
authorAnh Thao Pham (pta) <pta@odoo.com>2020-05-13 06:32:00 +0000
committerAnh Thao Pham (pta) <pta@odoo.com>2020-05-13 16:36:59 +0000
commitdbd87ec4648a18ebf3eb79e11214cf0ee5d1f5d2 (patch)
tree0f75ba7b455fe6970cc10cb11ba572e05131cbd8 /odoo/addons
parent27c3244116155cef3bb8477bc1e644aecc2c1cb8 (diff)
[FIX] base: fix import of studio customizations
- Activate Studio from dashboard of database A - Export studio customizations - Activate Studio from dashboard of database B - Import studio customizations previously exported The imported data don't have the boolean studio field set to True. Since v12, when loading a module, a query is executed to create or update XML ids. The create and write methods are not called anymore. Therefore the overridden create and write methods of "ir.model.data" defined in Studio module are not called and thus cannot set the studio field to True. The generation of the query creating XML ids has been moved to a private method allowing another module like Studio to override it. opw-2245578 closes odoo/odoo#51203 X-original-commit: 198ab837e466f3155ea1c3b35811b981b1c1e537 Related: odoo/enterprise#10586 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'odoo/addons')
-rw-r--r--odoo/addons/base/models/ir_model.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py
index 76f0d9b7c55..76b25c1dde0 100644
--- a/odoo/addons/base/models/ir_model.py
+++ b/odoo/addons/base/models/ir_model.py
@@ -1958,8 +1958,6 @@ class IrModelData(models.Model):
if not data_list:
return
- # rows to insert
- rowf = "(%s, %s, %s, %s, %s, now() at time zone 'UTC', now() at time zone 'UTC')"
rows = tools.OrderedSet()
for data in data_list:
prefix, suffix = data['xml_id'].split('.', 1)
@@ -1977,15 +1975,7 @@ class IrModelData(models.Model):
for sub_rows in self.env.cr.split_for_in_conditions(rows):
# insert rows or update them
- query = """
- INSERT INTO ir_model_data (module, name, model, res_id, noupdate, date_init, date_update)
- VALUES {rows}
- ON CONFLICT (module, name)
- DO UPDATE SET date_update=(now() at time zone 'UTC') {where}
- """.format(
- rows=", ".join([rowf] * len(sub_rows)),
- where="WHERE NOT ir_model_data.noupdate" if update else "",
- )
+ query = self._build_update_xmlids_query(sub_rows, update)
try:
self.env.cr.execute(query, [arg for row in sub_rows for arg in row])
except Exception:
@@ -1995,6 +1985,20 @@ class IrModelData(models.Model):
# update loaded_xmlids
self.pool.loaded_xmlids.update("%s.%s" % row[:2] for row in rows)
+ # NOTE: this method is overriden in web_studio; if you need to make another
+ # override, make sure it is compatible with the one that is there.
+ def _build_update_xmlids_query(self, sub_rows, update):
+ rowf = "(%s, %s, %s, %s, %s, now() at time zone 'UTC', now() at time zone 'UTC')"
+ return """
+ INSERT INTO ir_model_data (module, name, model, res_id, noupdate, date_init, date_update)
+ VALUES {rows}
+ ON CONFLICT (module, name)
+ DO UPDATE SET date_update=(now() at time zone 'UTC') {where}
+ """.format(
+ rows=", ".join([rowf] * len(sub_rows)),
+ where="WHERE NOT ir_model_data.noupdate" if update else "",
+ )
+
@api.model
def _load_xmlid(self, xml_id):
""" Simply mark the given XML id as being loaded, and return the