diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-09-15 18:09:39 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-09-15 18:09:39 +0200 |
| commit | 66ca68732431dd6bfc3c6df1fe17ef6fab98da40 (patch) | |
| tree | dc6ad0715b030fadddc5ed502aac9ba01a58a1b4 /addons/web/static/tests/fields | |
| parent | 6aebc800538b6fabd79c6cd1e819ef6d961e7589 (diff) | |
| parent | ed901bedcb7c8b840ae5cf4731b946e998b8b141 (diff) | |
[MERGE] forward port branch saas-17 up to ed901bedcb7
Diffstat (limited to 'addons/web/static/tests/fields')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 50 | ||||
| -rw-r--r-- | addons/web/static/tests/fields/upgrade_fields_tests.js | 22 |
2 files changed, 72 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 48245df73cf..fc969aeae87 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -1363,6 +1363,56 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('can_create and can_write option on a many2one', function (assert) { + assert.expect(5); + + this.data.product.options = { + can_create: "false", + can_write: "false", + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<sheet>' + + '<field name="product_id" can_create="false" can_write="false"/>' + + '</sheet>' + + '</form>', + archs: { + 'product,false,form': '<form string="Products"><field name="display_name"/></form>', + }, + mockRPC: function (route) { + if (route === '/web/dataset/call_kw/product/get_formview_id') { + return $.when(false); + } + return this._super.apply(this, arguments); + }, + }); + + form.$('.o_field_many2one input').click(); + assert.strictEqual($('.ui-autocomplete .o_m2o_dropdown_option:contains(Create)').length, 0, + "there shouldn't be any option to search and create"); + + $('.ui-autocomplete li:contains(xpad)').mouseenter().click(); + assert.strictEqual(form.$('.o_field_many2one input').val(), "xpad", + "the correct record should be selected"); + assert.strictEqual(form.$('.o_field_many2one .o_external_button').length, 1, + "there should be an external button displayed"); + + form.$('.o_field_many2one .o_external_button').click(); + assert.strictEqual($('.modal .o_form_view.o_form_readonly').length, 1, + "there should be a readonly form view opened"); + + $('.modal .o_form_button_cancel').click(); + + form.$('.o_field_many2one input').val('new product').trigger('keyup').trigger('focusout'); + + assert.strictEqual($('.modal').length, 0, "should not display the create modal"); + form.destroy(); + }); + QUnit.test('pressing enter in a m2o in an editable list', function (assert) { assert.expect(9); var done = assert.async(); diff --git a/addons/web/static/tests/fields/upgrade_fields_tests.js b/addons/web/static/tests/fields/upgrade_fields_tests.js index babc32b60a8..427ec7b54e3 100644 --- a/addons/web/static/tests/fields/upgrade_fields_tests.js +++ b/addons/web/static/tests/fields/upgrade_fields_tests.js @@ -39,6 +39,28 @@ QUnit.module('upgrade_fields', { form.destroy(); }); + QUnit.test('widget upgrade_boolean in a form view', function (assert) { + assert.expect(3); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<div class="o_field"><field name="bar" widget="upgrade_boolean"/></div>' + + '<div class="o_label"><label for="bar"/><div>Coucou</div></div>' + + '</form>', + }); + + assert.strictEqual(form.$('.o_field .label').length, 0, + "the upgrade label shouldn't be inside the field section"); + assert.strictEqual(form.$('.o_label .label').length, 1, + "the upgrade label should be inside the label section"); + assert.strictEqual(form.$('.o_label').text(), "Bar EnterpriseCoucou", + "the upgrade label should be inside the label section"); + form.destroy(); + }); + }); }); }); |
