Reviewers: ,
Please review this at http://codereview.tryton.org/594003/
Affected files:
M trytond/ir/translation.py
M trytond/model/modelsql.py
Index: trytond/ir/translation.py
===================================================================
--- a/trytond/ir/translation.py
+++ b/trytond/ir/translation.py
@@ -332,6 +332,21 @@
return len(ids)
@classmethod
+ def delete_ids(cls, model, ttype, ids):
+ "Delete translation for each id"
+ cursor = Transaction().cursor
+ translations = []
+ for i in range(0, len(ids), cursor.IN_MAX):
+ sub_ids = ids[i:i + cursor.IN_MAX]
+ translations += cls.search([
+ ('type', '=', ttype),
+ ('name', 'like', model + ',%'),
+ ('res_id', 'in', sub_ids),
+ ])
+ with Transaction().set_user(0):
+ cls.delete(translations)
+
+ @classmethod
def get_source(cls, name, ttype, lang, source=None):
"Return translation for source"
name = unicode(name)
Index: trytond/model/modelsql.py
===================================================================
--- a/trytond/model/modelsql.py
+++ b/trytond/model/modelsql.py
@@ -955,6 +955,7 @@
def delete(cls, records):
cursor = Transaction().cursor
pool = Pool()
+ Translation = pool.get('ir.translation')
ids = map(int, records)
if not ids:
@@ -1113,6 +1114,8 @@
cls.raise_user_error(error)
raise
+ Translation.delete_ids(cls.__name__, 'model', ids)
+
if cls._history:
for obj_id in ids:
cursor.execute('INSERT INTO "' + cls._table
+ '__history" ' \
--
[email protected] mailing list