summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-04-06 09:59:05 +0200
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commite7dfa4af775a93b291ccd570c05970f2ac2b9187 (patch)
treedc8589b6310f3a8cb7f2963fef50b18572c69018 /addons/web/static/src/js/fields/relational_fields.js
parent39ab5712ed58ccbc16736cc08d594fe50fedde39 (diff)
[FIX] web: add support for editable=top/bottom in o2m
Before this commit, we lost the functionality of editing records top or bottom. However, it as almost ready, but we needed to change the way commands are generated, to respect the actual order in the UI. Also, the mock server needed to be updated, to make sure he also save the new ids in the correct order.
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js4
1 files changed, 2 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 c7ff956fd7b..496aaee06f0 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -777,8 +777,8 @@ var FieldOne2Many = FieldX2Many.extend({
return this._super.apply(this, arguments).then(function () {
if (event && event.target === self && self.view.arch.tag === 'tree') {
if (event.data.changes[self.name].operation === 'CREATE') {
- // todo: get last record if editable = bottom
- var newID = self.value.data[0].id;
+ var index = self.editable === 'top' ? 0 : self.value.data.length - 1;
+ var newID = self.value.data[index].id;
self.renderer.editRecord(newID);
}
}