summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-05-02 18:53:44 +0200
committerChristophe Simonis <chs@odoo.com>2017-05-02 18:53:44 +0200
commitbf7de4d32ff30dd8b322d6c9c2cf2e9feb302e6f (patch)
treebdb67554300b520e41fec6dc32107d4b90156e40 /odoo
parenta97cb66961a77e9e3efb6de0d852e93f57afc350 (diff)
parent3f6bb0f544d5bdd102eb06fbc7d5aa9095efc235 (diff)
[MERGE] forward port branch saas-15 up to 3f6bb0f544d
Diffstat (limited to 'odoo')
-rw-r--r--odoo/addons/base/ir/ir_model.py26
-rw-r--r--odoo/tools/sql.py14
2 files changed, 24 insertions, 16 deletions
diff --git a/odoo/addons/base/ir/ir_model.py b/odoo/addons/base/ir/ir_model.py
index c6879746be8..ef41aedfb7e 100644
--- a/odoo/addons/base/ir/ir_model.py
+++ b/odoo/addons/base/ir/ir_model.py
@@ -1440,16 +1440,22 @@ class IrModelData(models.Model):
record = record.create(values)
if xml_id:
- for parent_model, parent_field in record._inherits.iteritems():
- if parent_model in existing_parents:
- continue
- self.sudo().create({
- 'name': xml_id + '_' + parent_model.replace('.', '_'),
- 'model': parent_model,
- 'module': module,
- 'res_id': record[parent_field].id,
- 'noupdate': noupdate,
- })
+ #To add an external identifiers to all inherits model
+ inherit_models = [record]
+ while inherit_models:
+ current_model = inherit_models.pop()
+ for parent_model_name, parent_field in current_model._inherits.iteritems():
+ inherit_models.append(self.env[parent_model_name])
+ if parent_model_name in existing_parents:
+ continue
+ self.sudo().create({
+ 'name': xml_id + '_' + parent_model_name.replace('.', '_'),
+ 'model': parent_model_name,
+ 'module': module,
+ 'res_id': record[parent_field].id,
+ 'noupdate': noupdate,
+ })
+ existing_parents.add(parent_model_name)
self.sudo().create({
'name': xml_id,
'model': model,
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py
index bd947dd913c..c4e9a143a8e 100644
--- a/odoo/tools/sql.py
+++ b/odoo/tools/sql.py
@@ -77,12 +77,14 @@ def convert_column(cr, tablename, columnname, columntype):
log_exceptions=False)
except psycopg2.NotSupportedError:
# can't do inplace change -> use a casted temp column
- query = 'ALTER TABLE "{0}" RENAME COLUMN "{1}" TO __temp_type_cast; ' \
- 'ALTER TABLE "{0}" ADD COLUMN "{1}" {2}; ' \
- 'UPDATE "{0}" SET "{1}"= __temp_type_cast::{2}' \
- 'ALTER TABLE "{0}" DROP COLUMN __temp_type_cast CASCADE'
- cr.execute(query.format(tablename, columntype, columntype))
- _schema.debug("Table %r: column %r changed to type %s", tablename, columntype, columntype)
+ query = '''
+ ALTER TABLE "{0}" RENAME COLUMN "{1}" TO __temp_type_cast;
+ ALTER TABLE "{0}" ADD COLUMN "{1}" {2};
+ UPDATE "{0}" SET "{1}"= __temp_type_cast::{2};
+ ALTER TABLE "{0}" DROP COLUMN __temp_type_cast CASCADE;
+ '''
+ cr.execute(query.format(tablename, columnname, columntype))
+ _schema.debug("Table %r: column %r changed to type %s", tablename, columnname, columntype)
def set_not_null(cr, tablename, columnname):
""" Add a NOT NULL constraint on the given column. """