diff --git a/trytond/ir/model.py b/trytond/ir/model.py index f882ef5945..c36098da90 100644 --- a/trytond/ir/model.py +++ b/trytond/ir/model.py @@ -278,6 +278,7 @@ class ModelData(ModelSQL, ModelView): date_init = fields.DateTime('Init Date') values = fields.Text('Values') inherit = fields.Boolean('Inherit') + noupdate = fields.Boolean('No Update') def __init__(self): super(ModelData, self).__init__() @@ -292,6 +293,9 @@ class ModelData(ModelSQL, ModelView): def default_inherit(self, cursor, user, context=None): return False + def default_noupdate(self, cursor, user, context=None): + return False + def get_id(self, cursor, user, module, fs_id): """ Return for an fs_id the corresponding db_id. diff --git a/trytond/ir/translation.py b/trytond/ir/translation.py index 642652dacc..875c17b885 100644 --- a/trytond/ir/translation.py +++ b/trytond/ir/translation.py @@ -383,11 +383,11 @@ class Translation(ModelSQL, ModelView, Cacheable): model_data_ids = model_data_obj.search(cursor, user, [ ('module', '=', module), ], context=context) - fs_id2db_id = {} + fs_id2model_data = {} for model_data in model_data_obj.browse(cursor, user, model_data_ids, context=context): - fs_id2db_id.setdefault(model_data.model, {}) - fs_id2db_id[model_data.model][model_data.fs_id] = model_data.db_id + fs_id2model_data.setdefault(model_data.model, {}) + fs_id2model_data[model_data.model][model_data.fs_id] = model_data translation_ids = [] reader = csv.reader(datas) @@ -420,10 +420,13 @@ class Translation(ModelSQL, ModelView, Cacheable): src = row[3].decode('utf-8') value = row[4].decode('utf-8') fuzzy = bool(int(row[5])) + noupdate = False model = name.split(',')[0] - if model in fs_id2db_id: - res_id = fs_id2db_id[model].get(res_id, res_id) + if model in fs_id2model_data and res_id in fs_id2model_data[model]: + model_data = fs_id2model_data[model][res_id] + res_id = model_data.db_id + noupdate = model_data.noupdate try: res_id = int(res_id) @@ -456,7 +459,7 @@ class Translation(ModelSQL, ModelView, Cacheable): if translation.value != value \ or translation.fuzzy != fuzzy: ids2.append(translation.id) - if ids2: + if ids2 and not noupdate: self.write(cursor, 0, ids2, { 'value': value, 'fuzzy': fuzzy, diff --git a/trytond/tools/convert.py b/trytond/tools/convert.py index 92b75f49dd..f01ec49c4a 100644 --- a/trytond/tools/convert.py +++ b/trytond/tools/convert.py @@ -449,7 +449,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler): self.taghandler.startElement(name, attributes) elif name == "data": - self.noupdate = attributes.get("noupdate", False) + self.noupdate = bool(int(attributes.get("noupdate", '0'))) elif name == "tryton": pass @@ -899,6 +899,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler): 'db_id': inherit_db_ids[table], 'values': str(values), 'inherit': True, + 'noupdate': self.noupdate, }) mdata_id = self.modeldata_obj.create(cursor, user, { @@ -907,6 +908,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler): 'module': module, 'db_id': db_id, 'values': str(values), + 'noupdate': self.noupdate, }) # update fs2db: