summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-03-14 10:51:30 +0100
committerGéry Debongnie <ged@odoo.com>2018-03-14 17:03:18 +0100
commit4586b876f273181b57f3f3fe4b0dce2a2d26b27a (patch)
treeef843ee8a8be9a1f7f712940065ca010bf18dbd4 /addons/web/static/src/js/fields
parent4fd9db52a26701ca1ae028a8e625beaa0550ea62 (diff)
[FIX] web: unselect current row before changing page
The issue here is quite simple. If we are editing a multipage one2many field, then we click on the pager, we need to properly unselect the current row. If we do not do that, then we can enter invalid data. For example, assume that there is a readonly field. We click on add, it creates a (virtual) record with no value for that field. When we click on the pager, we select the next page, and bypass all validation.
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 5856b59455a..aa71fca9c25 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -876,10 +876,15 @@ var FieldX2Many = AbstractField.extend({
this.pager = new Pager(this, this.value.count, this.value.offset + 1, this.value.limit, {
single_page_hidden: true,
withAccessKey: false,
+ validate: function () {
+ var isList = self.view.arch.tag === 'tree';
+ // TODO: we should have some common method in the basic renderer...
+ return isList ? self.renderer.unselectRow() : $.when();
+ },
});
this.pager.on('pager_changed', this, function (new_state) {
- this.trigger_up('load', {
- id: this.value.id,
+ self.trigger_up('load', {
+ id: self.value.id,
limit: new_state.limit,
offset: new_state.current_min - 1,
on_success: function (value) {