summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorKhoi Nguyen <bng@odoo.com>2017-08-03 09:25:16 +0200
committerKhoi Nguyen <bng@odoo.com>2017-08-04 11:31:58 +0200
commitc300e5ede781f16b7d00cdcbc6bad227b265dd6b (patch)
treef2692078bb6dd4301809531a1059ae338e4750a8 /addons/web/static/tests/fields/relational_fields_tests.js
parentd19671f0d0ff7189055cbe0794afed32f8a387e6 (diff)
[FIX] web: reload right record when editing a many2one inside an x2many
Before this revision, editing a many2one inside an x2many field did not cause an update of the x2many field upon saving. This is due to the fact that a field on a screen was deemed affected by a record change only if its value or a directly related record has been updated. This present revision looks for changes recursively, thereby including the case where an x2many field contains a many2one. The bug appeared for example in Manufacturing, when editing the product name of a BOM line.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js52
1 files changed, 52 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 0ad9aa2a416..f9b6e9dfaeb 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -1418,6 +1418,58 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('updating a many2one from a many2many', function (assert) {
+ assert.expect(4);
+
+ this.data.turtle.records[1].turtle_trululu = 1;
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<group>' +
+ '<field name="turtles">' +
+ '<tree editable="bottom">' +
+ '<field name="display_name"/>' +
+ '<field name="turtle_trululu"/>' +
+ '</tree>' +
+ '</field>' +
+ '</group>' +
+ '</form>',
+ res_id: 1,
+ archs: {
+ 'partner,false,form': '<form string="Trululu"><field name="display_name"/></form>',
+ },
+ mockRPC: function (route, args) {
+ if (args.method === 'get_formview_id') {
+ assert.deepEqual(args.args[0], [1], "should call get_formview_id with correct id");
+ return $.when(false);
+ }
+ return this._super(route, args);
+ },
+ });
+
+ // Opening the modal
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_data_row td:contains(first record)').click();
+ form.$('.o_external_button').click();
+ assert.strictEqual($('.modal').length, 1,
+ "should have one modal in body");
+
+ // Changing the 'trululu' value
+ $('.modal input[name="display_name"]').val('test').trigger('input');
+ $('.modal button.btn-primary').click();
+
+ // Test whether the value has changed
+ assert.strictEqual($('.modal').length, 0,
+ "the modal should be closed");
+ assert.equal(form.$('.o_data_cell:contains(test)').text(), 'test',
+ "the partner name should have been updated to 'test'");
+
+ form.destroy();
+ });
+
QUnit.module('FieldOne2Many');
QUnit.test('one2many basic properties', function (assert) {