From 91911159f5bc12046d791744ff23562378be047f Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 6 Jan 2015 18:50:28 +0100 Subject: [FIX] web: editable list, no re-rendering on field validation When adding several lines in an editable list (adding 7 lines to an invoice for instance), then clicking on the first row direcly after having filled the last line, the value of the cell sometimes had the value of the last line. Just a display bug, but still. Using internal_set_value avoid the re-rendering of the cell, and solve the above issue opw-620111 --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index aceb3e665fd..48df090a8d9 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3892,7 +3892,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ r = record; _.each(self.editor.form.fields, function(field){ field._inhibit_on_change_flag = true; - field.set_value(r.attributes[field.name]); + field.internal_set_value(r.attributes[field.name]); field._inhibit_on_change_flag = false; }); return _.every(self.editor.form.fields, function(field){ -- cgit v1.2.3 From 38aa984f31f525539d27f2bf47806352705830ba Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 9 Jan 2015 18:02:48 +0100 Subject: [FIX] web: avoid rendering fields on one2many list validation This rev. reverts 91911159f5bc12046d791744ff23562378be047f The above rev. was a good idea, except that internal_set_value expects the raw value, while the records attributes can be tuples(for instance, many2one are tuple(id, name) or list of command(one2many, many2many). set_value must be use here, as all fields (js) override set_value in order to handle their value repr (for instance, many2one fields handle the tuple (id,name). Besides, avoiding the re-render provides a huge performance improvment, as rerendering fields can lead to xmlrpc calls (for instance, re-rendering a many2one field implies calling the name_get method) opw-620111 opw-622108 --- addons/web/static/src/js/view_form.js | 29 +++++++++++++++++++------- addons/web/static/src/js/view_list_editable.js | 5 +++-- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 48df090a8d9..fd1fbdb22ad 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3094,7 +3094,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() { @@ -3328,14 +3328,14 @@ 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) { + this.view.render_value_defs.push(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; } self.display_value["" + self.get("value")] = data[0][1]; self.render_value(true); - }); + })); } }, display_string: function(str) { @@ -3741,7 +3741,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(); @@ -3888,12 +3888,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.internal_set_value(r.attributes[field.name]); - field._inhibit_on_change_flag = false; + field.set_value(r.attributes[field.name]); }); return _.every(self.editor.form.fields, function(field){ field.process_modifiers(); @@ -3901,6 +3908,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 8cb34418bdb..1fa3c0831b5 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -228,8 +228,9 @@ openerp.web.list_editable = function (instance) { 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 = {}; -- cgit v1.2.3 From 275367581bbf26496607224cff3b5c16340098b9 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 13 Jan 2015 12:44:16 +0100 Subject: [FIX] web: view is not always defined when a many2one is rendered This rev. is associated with rev. 38aa984f31f525539d27f2bf47806352705830ba closes #4660 --- addons/web/static/src/js/view_form.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index fd1fbdb22ad..5581ca7b0ae 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3328,14 +3328,17 @@ 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.view.render_value_defs.push(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; } self.display_value["" + self.get("value")] = data[0][1]; self.render_value(true); - })); + }); + if (this.view && this.view.render_value_defs){ + this.view.render_value_defs.push(def); + } } }, display_string: function(str) { -- cgit v1.2.3 From 8c3d71ccb88950ecc5741c76e7217e478e2f2988 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 13 Jan 2015 17:43:18 +0100 Subject: [CHG] Fix task 7536 / PR #499 differently Issue was the propagation of contextual values across actions, more precisely conserving the selected fiscal year when selecting an account from the chart of accounts tree view: the chart of accounts tree view is generally opened for a specific fiscal year, and it seemed sensible that opening an account would show only the journal items for the previously selected fiscal years rather than all items ever. PR #649 altered action.read by tentatively evaluating the action's context, however this has the side-effect of providing evaluated contexts when creating or editing actions via the UI, usually breaking them in the process (as the context at this point is basically nonsensical for the action's purpose). This backs out the previous fix, and creates a fix restricted to the tree view's JS (thereby removing the feature for window actions not invoked from a tree view). closes #4677, closes #4690 --- addons/web/static/src/js/view_tree.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js index 2f92042c4d0..380f1609a33 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 -- cgit v1.2.3 From fc9ce0bcff3f211dbb722a09a65af2a364c25acf Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 15 Jan 2015 15:37:16 +0100 Subject: [FIX] website_forum: description not translated Make the field description on a forum translatable and add it in the forum view. opw 619786 --- addons/web/static/src/js/openerpframework.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/openerpframework.js b/addons/web/static/src/js/openerpframework.js index 007edae7220..8b674afb0f0 100644 --- a/addons/web/static/src/js/openerpframework.js +++ b/addons/web/static/src/js/openerpframework.js @@ -1272,6 +1272,9 @@ openerp.TranslationDataBase = openerp.Class.extend(/** @lends instance.Translati add_module_translation: function(mod) { var self = this; _.each(mod.messages, function(message) { + if (message.id === 'Create a product') { + debugger; + } self.db[message.id] = message.string; }); }, @@ -1285,6 +1288,9 @@ openerp.TranslationDataBase = openerp.Class.extend(/** @lends instance.Translati return fcnt; }, get: function(key) { + if (key === 'Create a product') { + debugger; + } return this.db[key]; }, /** -- cgit v1.2.3 From 48002b3278df3808549d68fcad7fa178c99b88d2 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 15 Jan 2015 15:38:16 +0100 Subject: [FIX] web: debugger in previous commit Damn you commit -a --- addons/web/static/src/js/openerpframework.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/openerpframework.js b/addons/web/static/src/js/openerpframework.js index 8b674afb0f0..007edae7220 100644 --- a/addons/web/static/src/js/openerpframework.js +++ b/addons/web/static/src/js/openerpframework.js @@ -1272,9 +1272,6 @@ openerp.TranslationDataBase = openerp.Class.extend(/** @lends instance.Translati add_module_translation: function(mod) { var self = this; _.each(mod.messages, function(message) { - if (message.id === 'Create a product') { - debugger; - } self.db[message.id] = message.string; }); }, @@ -1288,9 +1285,6 @@ openerp.TranslationDataBase = openerp.Class.extend(/** @lends instance.Translati return fcnt; }, get: function(key) { - if (key === 'Create a product') { - debugger; - } return this.db[key]; }, /** -- cgit v1.2.3 From ec9a543014a91be17398ba6e443578fe37c3a885 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Mon, 19 Jan 2015 01:41:08 +0100 Subject: [FIX] dbmanager: backup support both zip and pg_dump custom format - let the user choose between the pg_dump custom format or the zip format including the filestore - use file objects to allow dumps larger than memory - postgres subprocess invocation is now clean and thread-safe, we dont touch the local process environ anymore - add a manifest to the zip dump format with version information about odoo, postgres (pg_dump doesnt output it) and modules --- addons/web/static/src/xml/base.xml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 9b80a868c6d..864bc899960 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -225,6 +225,15 @@ + + + + + + -- cgit v1.2.3 From af8c2e4db6b44019e2c649088e9eca8263ff3e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 16 Jan 2015 10:26:09 +0100 Subject: [IMP] pyeval: implement weekday function courtesy of mva. This adds the weekday function to date objects in pyeval. This will be useful for adding better filters (such as this week) in the searchview. --- addons/web/static/src/js/pyeval.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js index 57e2eaa1499..4cb17e70f29 100644 --- a/addons/web/static/src/js/pyeval.js +++ b/addons/web/static/src/js/pyeval.js @@ -517,6 +517,9 @@ toordinal: function () { return py.float.fromJSON(ymd2ord(this.year, this.month, this.day)); }, + weekday: function () { + return py.float.fromJSON((this.toordinal().toJSON()+6)%7); + }, fromJSON: function (year, month, day) { return py.PY_call(datetime.date, [year, month, day]); }, -- cgit v1.2.3