summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-01-19 17:15:56 +0100
committerChristophe Simonis <chs@odoo.com>2015-01-19 17:15:56 +0100
commit18e22be138f4d273ce8f63c0ff2c8a437cf6ce5d (patch)
tree63bd658de7b6fa0e91d521ca19322dd68bdc1492 /addons/web/static/src/js
parentf6e5bf847b1a7107c09b009a757823b0f9514fa4 (diff)
parent0aab81cd3ac6881b2b64ccedb901b55badd421d4 (diff)
[MERGE] forward port of branch 8.0 up to 0aab81c
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/view_form.js28
-rw-r--r--addons/web/static/src/js/view_list_editable.js5
-rw-r--r--addons/web/static/src/js/view_tree.js22
3 files changed, 35 insertions, 20 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 296c78d8d6d..abbc1330804 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -3554,7 +3554,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
reinit_value: function(val) {
this.internal_set_value(val);
this.floating = false;
- if (this.is_started)
+ if (this.is_started && !this.no_rerender)
this.render_value();
},
initialize_field: function() {
@@ -3805,7 +3805,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
}
if (! no_recurse) {
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
- this.alive(dataset.name_get([self.get("value")])).done(function(data) {
+ var def = this.alive(dataset.name_get([self.get("value")])).done(function(data) {
if (!data[0]) {
self.do_warn(_t("Render"), _t("No value found for the field "+self.field.string+" for value "+self.get("value")));
return;
@@ -3818,6 +3818,9 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
self.display_value["" + self.get("value")] = self.display_value_backup["" + self.get("value")];
self.render_value(true);
});
+ if (this.view && this.view.render_value_defs){
+ this.view.render_value_defs.push(def);
+ }
}
},
display_string: function(str) {
@@ -4293,7 +4296,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
this.dataset.index = 0;
}
this.trigger_on_change();
- if (this.is_started) {
+ if (this.is_started && !this.no_rerender) {
return self.reload_current_view();
} else {
return $.when();
@@ -4437,12 +4440,19 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
return true;
}
var r;
- return _.every(this.records.records, function(record){
+ if (_.isEmpty(this.records.records)){
+ return true;
+ }
+ current_values = {};
+ _.each(this.editor.form.fields, function(field){
+ field._inhibit_on_change_flag = true;
+ field.no_rerender = true;
+ current_values[field.name] = field.get('value');
+ });
+ var valid = _.every(this.records.records, function(record){
r = record;
_.each(self.editor.form.fields, function(field){
- field._inhibit_on_change_flag = true;
field.set_value(r.attributes[field.name]);
- field._inhibit_on_change_flag = false;
});
return _.every(self.editor.form.fields, function(field){
field.process_modifiers();
@@ -4450,6 +4460,12 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
return field.is_valid();
});
});
+ _.each(this.editor.form.fields, function(field){
+ field.set('value', current_values[field.name]);
+ field._inhibit_on_change_flag = false;
+ field.no_rerender = false;
+ });
+ return valid;
},
do_add_record: function () {
if (this.editable()) {
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index 831d383c731..77559504060 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -231,8 +231,9 @@
this.records.add(record, {
at: this.prepends_on_create() ? 0 : null});
}
-
- return this.ensure_saved().then(function () {
+ return this.ensure_saved().then(function(){
+ return $.when.apply(null, self.editor.form.render_value_defs);
+ }).then(function () {
var $recordRow = self.groups.get_row_for(record);
var cells = self.get_cells_for($recordRow);
var fields = {};
diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js
index 68915077a48..06e19e28ca9 100644
--- a/addons/web/static/src/js/view_tree.js
+++ b/addons/web/static/src/js/view_tree.js
@@ -222,27 +222,25 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
var local_context = {
active_model: self.dataset.model,
active_id: id,
- active_ids: [id]};
+ active_ids: [id]
+ };
+ var ctx = instance.web.pyeval.eval(
+ 'context', new instance.web.CompoundContext(
+ this.dataset.get_context(), local_context));
return this.rpc('/web/treeview/action', {
id: id,
model: this.dataset.model,
- context: instance.web.pyeval.eval(
- 'context', new instance.web.CompoundContext(
- this.dataset.get_context(), local_context))
+ context: ctx
}).then(function (actions) {
if (!actions.length) { return; }
var action = actions[0][2];
- var c = new instance.web.CompoundContext(local_context);
+ var c = new instance.web.CompoundContext(local_context).set_eval_context(ctx);
if (action.context) {
c.add(action.context);
}
- return instance.web.pyeval.eval_domains_and_contexts({
- contexts: [c], domains: []
- }).then(function (res) {
- action.context = res.context;
- return self.do_action(action);
- }, null);
- }, null);
+ action.context = c;
+ return self.do_action(action);
+ });
},
// show & hide the contents