summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorDharmang Soni <dpr@openerp.com>2018-04-25 11:10:51 +0530
committerAaron Bohy <aab@odoo.com>2018-08-14 13:51:07 +0200
commit4dfabb8f7adde06a7936502af61534c9958ed4f7 (patch)
tree4f349b97a09e78f0042e9088ae598ff7b7271407 /addons/web/static/tests/fields/relational_fields_tests.js
parent92bdd0e7c5a4ba13f1874e1aec2e379745e5660e (diff)
[IMP] web: FieldSelection: no empty value if required
From this rev., the empty value isn't available in the options of required selection fields, thus preventing the user to unset it. Related to task #49262 Closes #24404
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js35
1 files changed, 35 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 62821027c5b..950a3dcd8fe 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -11558,6 +11558,41 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('required selection widget should not have blank option', function (assert) {
+ assert.expect(3);
+
+ this.data.partner.fields.feedback_value = {
+ type: "selection",
+ required: true,
+ selection : [['good', 'Good'], ['bad', 'Bad']],
+ default: 'good',
+ string: 'Good'
+ };
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="feedback_value"/>' +
+ '<field name="color" attrs="{\'required\': [(\'feedback_value\', \'=\', \'bad\')]}"/>' +
+ '</form>',
+ res_id: 1
+ });
+
+ form.$buttons.find('.o_form_button_edit').click();
+ assert.strictEqual(form.$('.o_field_widget[name=color]')[0].options.length, 3,
+ "non required selection field must have 3 options 1 blank option and 2 value options");
+ assert.strictEqual(form.$('.o_field_widget[name=feedback_value]')[0].options.length, 2,
+ "should have only 2 options without blank option");
+
+ // change value to update widget modifier values
+ form.$('.o_field_widget[name=feedback_value]').val('"bad"').trigger('change');
+ assert.strictEqual(form.$('.o_field_widget[name=color]')[0].options.length, 2,
+ "should have only 2 options");
+
+ form.destroy();
+ });
+
QUnit.module('FieldMany2ManyTags');
QUnit.test('fieldmany2many tags with and without color', function (assert) {