summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-12-06 12:39:06 +0000
committerGéry Debongnie <ged@odoo.com>2018-12-07 13:16:06 +0000
commit40dd121938552d3f88289d2e5fcd1d57a0dd01bb (patch)
tree4830c8ffdea1e10d35c7ddf096f536bd8999240f /addons/web/static/tests/fields/relational_fields/field_many2many_tests.js
parent48a50b4bc011fc6dfc82a673f921fad941dc79cf (diff)
[REF] web: move ControlPanel inside controllers/actions
This branch introduces a large-scale reorganization of the component tree generated by the web client. The short version is that now, the control panel is a child of the view controller and no longer a sibling. Graphically (and simplified), we go from this: webClient / | \ ... ... actionManager / \ controlPanel viewController / \ to this: webClient / | \ ... ... actionManager | viewController / | \ ControlPanelController / \ CPRenderer CPModel The motivation is that this work moves the code where it should be. Before this commit, it was kind of weird to have code in the controllers to render buttons outside of their root node (in renderButtons). Also, the action manager had to take care of coordinating search view states between view transitions. So, this work simplifies the code. It also makes it easier to extend. We see day after day that Odoo needs to take care of more complex UI needs, and in many cases, these needs were quite difficult to implement (we prefer spaghettis in our plates, not in our code). The changes in this branch should open the way to implement these features. For example, - it will now be easy to add the possibility of views (for example, the search view or a new ControlPanel view) to add custom buttons (of type action or object) in the control panel. - Another need will be to serialize/ restore the state of the search view across action boundaries (needed by the dashboard). - Another example is the possibility for views to customize easily the presence/absence of sub menus (filters/groupbys/favorites/ time range/...) - Another need is an easier way for views/client action to customize their control panel. This commit also contains a large rewrite of the search view (so it is more inline with our architecture and easier to maintain). Part of task 1893568 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields/field_many2many_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_many2many_tests.js85
1 files changed, 19 insertions, 66 deletions
diff --git a/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js b/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js
index e6f2c06173f..949af90fafe 100644
--- a/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js
+++ b/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js
@@ -262,7 +262,7 @@ QUnit.module('fields', {}, function () {
'the removed record should not be in kanban anymore');
// save the record
- testUtils.form.clickSave(form);;
+ testUtils.form.clickSave(form);
form.destroy();
});
@@ -431,7 +431,7 @@ QUnit.module('fields', {}, function () {
'the updated row still has the correct values');
// save
- testUtils.form.clickSave(form);;
+ testUtils.form.clickSave(form);
assert.containsN(form, '.o_list_view td.o_list_number', 2,
'should contain 2 subrecords');
assert.strictEqual(form.$('.o_list_view .o_data_row td:first').text(),
@@ -545,7 +545,7 @@ QUnit.module('fields', {}, function () {
'new name', 'the updated row still has the correct values');
// save
- testUtils.form.clickSave(form);;
+ testUtils.form.clickSave(form);
assert.containsN(form, '.o_list_view td.o_list_number', 2,
'should contain 2 subrecords');
assert.strictEqual(form.$('.o_list_view .o_data_row td:first').text(),
@@ -687,73 +687,26 @@ QUnit.module('fields', {}, function () {
}
});
- assert.notOk(form.$('.custom-checkbox input').eq(0).prop('checked'),
+ assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(0).prop('checked'),
"first checkbox should not be checked");
- assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'),
+ assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(1).prop('checked'),
"second checkbox should not be checked");
- assert.ok(form.$('.custom-checkbox input').eq(2).prop('checked'),
+ assert.ok(form.$('.o_form_view .custom-checkbox input').eq(2).prop('checked'),
"third checkbox should be checked");
- testUtils.dom.click(form.$('.custom-checkbox input:checked'));
- testUtils.dom.click(form.$('.custom-checkbox input').first());
- testUtils.dom.click(form.$('.custom-checkbox input').first());
- testUtils.dom.click(form.$('.custom-checkbox input').first());
+ testUtils.dom.click(form.$('.o_form_view .custom-checkbox input:checked'));
+ testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first());
+ testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first());
+ testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first());
- assert.ok(form.$('.custom-checkbox input').eq(0).prop('checked'),
+ assert.ok(form.$('.o_form_view .custom-checkbox input').eq(0).prop('checked'),
"first checkbox should be checked");
- assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'),
+ assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(1).prop('checked'),
"second checkbox should not be checked");
- assert.notOk(form.$('.custom-checkbox input').eq(2).prop('checked'),
+ assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(2).prop('checked'),
"third checkbox should not be checked");
- testUtils.form.clickSave(form);;
-
- form.destroy();
- });
-
- QUnit.test('many2many checkboxes with default values', function (assert) {
- assert.expect(7);
-
- this.data.partner.fields.turtles.default = [3];
- this.data.partner.fields.turtles.type = "many2many";
-
- var form = createView({
- View: FormView,
- model: 'partner',
- data: this.data,
- arch: '<form string="Partners">' +
- '<field name="turtles" widget="many2many_checkboxes">' +
- '</field>' +
- '</form>',
- mockRPC: function (route, args) {
- if (args.method === 'create') {
- assert.deepEqual(args.args[0].turtles, [[6, false, [1]]],
- "correct values should have been sent to create");
- }
- return this._super.apply(this, arguments);
- }
- });
-
- assert.notOk(form.$('.custom-checkbox input').eq(0).prop('checked'),
- "first checkbox should not be checked");
- assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'),
- "second checkbox should not be checked");
- assert.ok(form.$('.custom-checkbox input').eq(2).prop('checked'),
- "third checkbox should be checked");
-
- testUtils.dom.click(form.$('.custom-checkbox input:checked'));
- testUtils.dom.click(form.$('.custom-checkbox input').first());
- testUtils.dom.click(form.$('.custom-checkbox input').first());
- testUtils.dom.click(form.$('.custom-checkbox input').first());
-
- assert.ok(form.$('.custom-checkbox input').eq(0).prop('checked'),
- "first checkbox should be checked");
- assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'),
- "second checkbox should not be checked");
- assert.notOk(form.$('.custom-checkbox input').eq(2).prop('checked'),
- "third checkbox should not be checked");
-
- testUtils.form.clickSave(form);;
+ testUtils.form.clickSave(form);
form.destroy();
});
@@ -904,7 +857,7 @@ QUnit.module('fields', {}, function () {
testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
// there is nothing left to save -> should not do a 'write' RPC
- testUtils.form.clickSave(form);;
+ testUtils.form.clickSave(form);
assert.verifySteps([
'read', // read initial record (on partner)
@@ -980,27 +933,27 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40,
'there should be 40 records displayed on page 1');
- testUtils.dom.click(form.$('.o_pager_next'));
+ testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next'));
assert.verifySteps(['read', 'onchange', 'read', 'read']);
assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(),
'41-45 / 45', "pager should be correct");
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 5,
'there should be 5 records displayed on page 2');
- testUtils.form.clickSave(form);;
+ testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(),
'1-40 / 45', "pager should be correct");
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40,
'there should be 40 records displayed on page 1');
- testUtils.dom.click(form.$('.o_pager_next'));
+ testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next'));
assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(),
'41-45 / 45', "pager should be correct");
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 5,
'there should be 5 records displayed on page 2');
- testUtils.dom.click(form.$('.o_pager_next'));
+ testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next'));
assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(),
'1-40 / 45', "pager should be correct");
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40,