summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-04-20 14:43:19 +0200
committerLucas Perais (lpe) <lpe@odoo.com>2018-05-02 11:09:50 +0200
commit27c9f838d35f36f6fe8d68068ed96c5c58d9d186 (patch)
treeba48e5904db2594d855e5446851f0332d9ca8f89 /addons/web/static/tests/fields/relational_fields_tests.js
parente0424b960315b8328f7da96f9d5bc58f2628cd47 (diff)
[FIX] web: inline views should share their fields
Have a One2Many The views of that o2m define two inline views: the list and the form in the list view, put a field that isn't in the form and used in a domain Try to add an item to the list The form pops up Fill in the data and save & close Before this commit: It crashed when evaluating the domain on a field using the field that is not in the form After this commit: Subviews share their fields in a special object on the parent record In our case, the form view checks in that shared resource if the fields it is supposed to initialize are there. Hence, this flow doesn't crash anymore OPW 1837511 closes #24350
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js46
1 files changed, 45 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index dcc765dfc6e..7f392e5e33b 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -2330,6 +2330,50 @@ QUnit.module('relational_fields', {
QUnit.module('FieldOne2Many');
+ QUnit.test('one2many with two inline views', function (assert) {
+ assert.expect(1);
+
+ // The inline list view has and uses a field that the inline form view doesn't have
+ // We need to test that returning from the form view to the list view unfolds smoothly
+ // Even if a field needed in the list is not set in the form
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="turtles">' +
+ '<tree>' +
+ '<field name="turtle_foo"/>' +
+ '<field name="display_name" attrs="{\'readonly\': [(\'turtle_foo\', \'=\', \'lol\')]}"/>' +
+ '</tree>' +
+ '<form>' +
+ '<field name="display_name"/>' +
+ '</form>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ // Add a record with the form view
+ form.$('.o_field_x2many_list .o_field_x2many_list_row_add a').click();
+ var modal = $('.modal-dialog');
+ // Fill in the only field
+ modal.find('input[name=display_name]').val('lol').trigger('input');
+ // Save the record
+ modal.find('.btn-primary').first().click();
+
+ // Now back to the list, verifying that the record is present
+ var $newRecord = form.$('.o_field_x2many_list tbody .o_data_row').eq(1);
+ assert.equal($newRecord.find('.o_data_cell').eq(1).text(), 'lol',
+ 'We should have created a record in the One2Many');
+
+ form.destroy();
+ });
+
QUnit.test('one2many list editable with cell readonly modifier', function (assert) {
assert.expect(4);
@@ -5692,7 +5736,7 @@ QUnit.module('relational_fields', {
rpcCount++;
if (args.method === 'write') {
assert.deepEqual(args.args[1].p, [[0, args.args[1].p[0][1], {
- int_field: 123, product_id: 41
+ int_field: 123, product_id: 41, foo: false,
}]]);
}
return this._super(route, args);