|
@ -14,6 +14,7 @@ var Dialog = require('web.Dialog'); |
|
|
var FormView = require('web.FormView'); |
|
|
var FormView = require('web.FormView'); |
|
|
var View = require('web.AbstractView'); |
|
|
var View = require('web.AbstractView'); |
|
|
var session = require('web.session'); |
|
|
var session = require('web.session'); |
|
|
|
|
|
var rpc = require('web.rpc'); |
|
|
|
|
|
|
|
|
var _t = core._t; |
|
|
var _t = core._t; |
|
|
var QWeb = core.qweb; |
|
|
var QWeb = core.qweb; |
|
@ -118,11 +119,10 @@ var translateDialog = Dialog.extend({ |
|
|
|
|
|
|
|
|
this.$el.find('.oe_translation_field').val('').removeClass('touched'); |
|
|
this.$el.find('.oe_translation_field').val('').removeClass('touched'); |
|
|
_.each(self.languages, function(lg) { |
|
|
_.each(self.languages, function(lg) { |
|
|
var context = session.user_context; |
|
|
|
|
|
context.lang = lg.code; |
|
|
|
|
|
|
|
|
var context = new Context(session.user_context, {lang: lg.code}); |
|
|
var deff = $.Deferred(); |
|
|
var deff = $.Deferred(); |
|
|
deferred.push(deff); |
|
|
deferred.push(deff); |
|
|
self._rpc({ |
|
|
|
|
|
|
|
|
rpc.query({ |
|
|
model: self.view.modelName, |
|
|
model: self.view.modelName, |
|
|
method: 'read', |
|
|
method: 'read', |
|
|
args: [ |
|
|
args: [ |
|
@ -130,7 +130,7 @@ var translateDialog = Dialog.extend({ |
|
|
], |
|
|
], |
|
|
kwargs: { |
|
|
kwargs: { |
|
|
fields: self.translatable_fields, |
|
|
fields: self.translatable_fields, |
|
|
context: context, |
|
|
|
|
|
|
|
|
context: context.eval(), |
|
|
}, |
|
|
}, |
|
|
}).done( |
|
|
}).done( |
|
|
function (rows) { |
|
|
function (rows) { |
|
@ -156,22 +156,25 @@ var translateDialog = Dialog.extend({ |
|
|
}); |
|
|
}); |
|
|
_.each(translations, function(text, code) { |
|
|
_.each(translations, function(text, code) { |
|
|
save_mutex.exec(function() { |
|
|
save_mutex.exec(function() { |
|
|
var context = new Context(session.user_context); |
|
|
|
|
|
context.lang = code; |
|
|
|
|
|
self._rpc({ |
|
|
|
|
|
|
|
|
var done = new $.Deferred(); // holds the mutex
|
|
|
|
|
|
|
|
|
|
|
|
var context = new Context(session.user_context, {lang: code}); |
|
|
|
|
|
rpc.query({ |
|
|
model: self.view.modelName, |
|
|
model: self.view.modelName, |
|
|
method: 'write', |
|
|
method: 'write', |
|
|
args: [self.res_id, text], |
|
|
args: [self.res_id, text], |
|
|
kwargs: {context: context} |
|
|
|
|
|
|
|
|
kwargs: {context: context.eval()} |
|
|
|
|
|
}).then(function() { |
|
|
|
|
|
done.resolve(); |
|
|
}); |
|
|
}); |
|
|
if (code === self.view_language) { |
|
|
if (code === self.view_language) { |
|
|
_.each(text, function(value, key) { |
|
|
_.each(text, function(value, key) { |
|
|
self.view.$el.find('input[name="'+ key + '"]').val(value); |
|
|
self.view.$el.find('input[name="'+ key + '"]').val(value); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
return done; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
session.user_context.lang = self.view_language; |
|
|
|
|
|
this.close(); |
|
|
this.close(); |
|
|
}, |
|
|
}, |
|
|
on_button_close: function() { |
|
|
on_button_close: function() { |
|
|