From 6602e1cf2dccbd0cbdcdf3e5e4547dbc6f0c5b6d Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 23 Aug 2019 08:40:16 +0000 Subject: [FIX] web: grouped list with node and onchange MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's assume an editable grouped list view with a node containing subfields, and an onchange. Edit a row to trigger the onchange. Before this rev., it crashed because the onchange specs was incorrect: it followed the relation of the many2one and thus included its subfields (whereas it should only follow the relation for x2many fields). For example, go to Accounting > Accounting > Sales and edit the label of a move line. Task 2044187 closes odoo/odoo#36001 Signed-off-by: Géry Debongnie (ged) --- addons/web/static/src/js/views/basic/basic_model.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 3bd11a9722a..eca8388aaa4 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2001,9 +2001,11 @@ var BasicModel = AbstractModel.extend({ if (field.onChange) { hasOnchange = true; } - _.each(fieldInfo.views, function (view) { - generateSpecs(view.fieldsInfo[view.type], view.fields, key + '.'); - }); + if (field.type === 'one2many' || field.type === 'many2many') { + _.each(fieldInfo.views, function (view) { + generateSpecs(view.fieldsInfo[view.type], view.fields, key + '.'); + }); + } }); } return hasOnchange ? specs : false; -- cgit v1.2.3 From 39e5d93c97e96514a3b48ab8c35f24b4400a200e Mon Sep 17 00:00:00 2001 From: RomainLibert Date: Mon, 9 Sep 2019 12:45:16 +0000 Subject: [FIX] web: use New as default value for breadcrumb Before this commit if `display_name` was in the view, the breadcrumb when creating a new record, the breadcrumb would display either `Unnamed`, either the last value of `_title` in `action_mixin`. The default value when creating a record should be `New`, but the return was ignored because `display_name` was found in the view closes odoo/odoo#36565 Signed-off-by: Yannick Tivisse (yti) --- addons/web/static/src/js/views/basic/basic_model.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index f7005a11b9a..614602a5791 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -678,13 +678,14 @@ var BasicModel = AbstractModel.extend({ */ getName: function (id) { var record = this.localData[id]; + var returnValue = ''; if (record._changes && 'display_name' in record._changes) { - return record._changes.display_name; + returnValue = record._changes.display_name; } - if ('display_name' in record.data) { - return record.data.display_name; + else if ('display_name' in record.data) { + returnValue = record.data.display_name; } - return _t("New"); + return returnValue || _t("New"); }, /** * Returns true if a record is dirty. A record is considered dirty if it has -- cgit v1.2.3