[FIX] web: radio widget ignores required attribute
opw-2729810 closes odoo/odoo#87918 X-original-commit: 65f4c4f29a9c747f114eb6359d3ebb036efab9d6 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -3449,14 +3449,6 @@ var FieldRadio = FieldSelection.extend({
|
||||
return checked.length ? checked : this.$("[data-index='0']");
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @returns {boolean} always true
|
||||
*/
|
||||
isSet: function () {
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Associates the 'for' attribute to the radiogroup, instead of the selected
|
||||
* radio button.
|
||||
|
||||
@@ -2329,6 +2329,34 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('required fieldradio widget on a many2one', async function (assert) {
|
||||
assert.expect(6);
|
||||
|
||||
const form = await createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form>' +
|
||||
'<field name="product_id" widget="radio" required="1"/>' +
|
||||
'</form>',
|
||||
});
|
||||
|
||||
testUtils.mock.intercept(form, 'call_service', function (event) {
|
||||
if (event.data.service === 'notification' && event.data.method === 'notify') {
|
||||
assert.step('danger');
|
||||
assert.equal(event.data.args[0].type, 'danger');
|
||||
assert.equal(event.data.args[0].title, 'Invalid fields:');
|
||||
assert.equal(event.data.args[0].message, '<ul><li>Product</li></ul>');
|
||||
}
|
||||
});
|
||||
|
||||
assert.containsNone(form, 'input:checked', "none of the input should be checked");
|
||||
|
||||
await testUtils.form.clickSave(form);
|
||||
assert.verifySteps(['danger']);
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('fieldradio change value by onchange', async function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user