From 9f49709ef3ea8a522baf1e0e1e0ca7061921636a Mon Sep 17 00:00:00 2001 From: Carlos Mayo Date: Wed, 13 Nov 2019 09:56:04 +0000 Subject: [FIX] web: many2many_checkboxes: react to domain changes Let's assume a many2many_checkboxes widget in a form view with a dynamic domain (depending on another field in the view). At first rendering, the widget contains a checkbox for each value matching the domain. Before this rev., if the user changed the value of the field used in the domain, the many2many_checkboxes wasn't redrawn, so it still displayed the values matching the previous version of the domain. Closes #38509 Closes #40173 closes odoo/odoo#42867 X-original-commit: 1ace56f9a8cb56fb39235468dd13447bcbbee40a Signed-off-by: Aaron Bohy (aab) Co-authored-by: Aaron Bohy --- addons/web/static/src/js/fields/relational_fields.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 0a3bb640f50..c1f116784fa 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -2571,17 +2571,27 @@ var FieldMany2ManyCheckBoxes = AbstractField.extend({ /** * @private */ - _render: function () { + _renderCheckboxes: function () { var self = this; - this._super.apply(this, arguments); + this.m2mValues = this.record.specialData[this.name]; + this.$el.html(qweb.render(this.template, {widget: this})); _.each(this.value.res_ids, function (id) { self.$('input[data-record-id="' + id + '"]').prop('checked', true); }); }, /** + * @override + * @private + */ + _renderEdit: function () { + this._renderCheckboxes(); + }, + /** + * @override * @private */ _renderReadonly: function () { + this._renderCheckboxes(); this.$("input").prop("disabled", true); }, -- cgit v1.2.3