diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-04-13 15:22:47 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-04-18 17:40:09 +0200 |
| commit | 05589db8232a68846cca2660c73914045b1fec5a (patch) | |
| tree | 7ff75e31704b24c89e5108f76343056d0f3d051c /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | 0e49ccc4196b5302fbd15d0b11026afb489ce10f (diff) | |
[FIX] web: don't ignore required attrs on image fields
Before this rev., falsy image fields could be saved even if they
were required.
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 909e778b60a..7f1742b3041 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1698,7 +1698,6 @@ QUnit.module('basic_fields', { assert.strictEqual(form.$('div[name="document"] > img').attr('width'), "90", "the image should correctly set its attributes"); form.destroy(); - }); QUnit.test('image fields in subviews are loaded correctly', function (assert) { @@ -1750,6 +1749,34 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('image fields with required attribute', function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<field name="document" required="1" widget="image"/>' + + '</form>', + mockRPC: function (route, args) { + if (args.method === 'create') { + throw new Error("Should not do a create RPC with unset required image field"); + } + return this._super.apply(this, arguments); + }, + }); + + form.$buttons.find('.o_form_button_save').click(); + + assert.ok(form.$('.o_form_view').hasClass('o_form_editable'), + "form view should still be editable"); + assert.ok(form.$('.o_field_widget').hasClass('o_field_invalid'), + "image field should be displayed as invalid"); + + form.destroy(); + }); + QUnit.module('JournalDashboardGraph', { beforeEach: function () { _.extend(this.data.partner.fields, { |
