summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2018-11-06 10:34:43 +0000
committerGéry Debongnie <ged@odoo.com>2018-11-09 15:04:18 +0000
commit45bc7c92f804c0e2329eadf62043742f6986aa47 (patch)
tree7017feefe85013391b1c431afca632d8f3146b12 /addons/web/static/tests/fields/relational_fields_tests.js
parent1620c5b69c6977d49c2bcea6d9cbf02c0db44878 (diff)
[FIX] web: extend the fieldsInfo of a view with the origin view to evaluate extra fields
Suppose you are editing a SO to add a new line. Depending on the configuration, a sale order line wizard may open (e.g. if packages are activated). This wizard is a form view, opened from the tree view of the sale order lines. We have commit 8e5156938a9c87b80512bff9ecd025891406e624 that adds extra fields from the originating view. (However it doesn't work if the other view is inlined, so we modify this part to add the extra field even in this case.) Then we need the field info from the origin view in the target view; we do so by extending the former with the content of the latter. opw 1904337 closes odoo/odoo#28441
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index f64e4e32e91..9c7c6363a40 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -13544,6 +13544,90 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('one2many with extra field from server not in (inline) form', function (assert) {
+ assert.expect(1);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="p" >' +
+ '<tree>' +
+ '<field name="datetime"/>' +
+ '<field name="display_name"/>' +
+ '</tree>' +
+ '<form>' +
+ '<field name="display_name"/>' +
+ '</form>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ var x2mList = form.$('.o_field_x2many_list[name=p]');
+
+ // Add a record in the list
+ x2mList.find('.o_field_x2many_list_row_add a').click();
+
+ var modal = $('.modal-lg');
+
+ var nameInput = modal.find('input.o_input[name=display_name]');
+ nameInput.val('michelangelo').trigger('input');
+
+ // Save the record in the modal (though it is still virtual)
+ modal.find('.btn-primary').first().click();
+
+ assert.equal(x2mList.find('.o_data_row').length, 1,
+ 'There should be 1 records in the x2m list');
+
+ form.destroy();
+ });
+
+ QUnit.test('one2many with extra X2many field from server not in inline form', function (assert) {
+ assert.expect(1);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="p" >' +
+ '<tree>' +
+ '<field name="turtles"/>' +
+ '<field name="display_name"/>' +
+ '</tree>' +
+ '<form>' +
+ '<field name="display_name"/>' +
+ '</form>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ var x2mList = form.$('.o_field_x2many_list[name=p]');
+
+ // Add a first record in the list
+ x2mList.find('.o_field_x2many_list_row_add a').click();
+
+ // Save & New
+ $('.modal-lg').find('.btn-primary').eq(1).click();
+
+ // Save & Close
+ $('.modal-lg').find('.btn-primary').eq(0).click();
+
+ assert.equal(x2mList.find('.o_data_row').length, 2,
+ 'There should be 2 records in the x2m list');
+
+ form.destroy();
+ });
+
QUnit.test('one2many invisible depends on parent field', function (assert) {
assert.expect(4);