summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2021-02-16 14:35:44 +0000
committerAaron Bohy <aab@odoo.com>2021-02-17 07:28:09 +0000
commitfa7a185663f21c1c4060765c8c137b296df3a350 (patch)
tree1363a69effb7bc2f778754a2c1a908526224ac91 /addons/web/static/tests
parent5e85ee521edb70d4d2c7cdbf59c29794a8cd98b9 (diff)
[FIX] web: list: correctly evaluate groupby modifier with m2o
Let's assume a <groupby> node in a list view containing a button with an invisible modifier referencing a many2one field, e.g. ``` <tree> <groupby> <field name="m2o" invisible="1"/> <button string="do it" attrs="{'invisible': [('m2o', '=', False)]}"/> </groupby> </tree> ``` Before this commit, the m2o field was correctly read, but it's value wasn't processed by the model, so the modifier wasn't correctly evaluated. Issue reported on PR https://github.com/odoo/odoo/pull/65316/ closes odoo/odoo#66287 X-original-commit: bbaeeb76bbef4ea371d3db5821af91bf1fe9ac4f Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/views/list_tests.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 481ec86a6e8..b33028f5b44 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -4741,6 +4741,39 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('groupby node with a button with modifiers using a many2one', async function (assert) {
+ assert.expect(5);
+
+ this.data.res_currency.fields.m2o = {string: "Currency M2O", type: "many2one", relation: "bar"};
+ this.data.res_currency.records[0].m2o = 1;
+
+ const list = await createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: `
+ <tree expand="1">
+ <field name="foo"/>
+ <groupby name="currency_id">
+ <field name="m2o"/>
+ <button string="Button 1" type="object" name="button_method" attrs='{"invisible": [("m2o", "=", false)]}'/>
+ </groupby>
+ </tree>`,
+ mockRPC(route, args) {
+ assert.step(args.method);
+ return this._super(...arguments);
+ },
+ groupBy: ['currency_id'],
+ });
+
+ assert.containsOnce(list, '.o_group_header:eq(0) button.o_invisible_modifier');
+ assert.containsOnce(list, '.o_group_header:eq(1) button:not(.o_invisible_modifier)');
+
+ assert.verifySteps(['web_read_group', 'read']);
+
+ list.destroy();
+ });
+
QUnit.test('reload list view with groupby node', async function (assert) {
assert.expect(2);