Selection field with widget="radio" not getting required effect applied with attrs in XML file in Odoo 12

Your code should work normally but if this problem is with the widget report a issue in Odoo Github :

For now just use api.constrains to get the same behavior

 # remember to depend on both fields
 @api.constrains('installments_calculation','repayment_method')
 def check_installments_calculation(self):
    for rec in self:
        if not rec.installments_calculation and rec.repayment_method == 'salary deduction':
            raise exception.ValidationError(_('You message here'))

I came up with a fix for the client side which is the approach that I was looking for:

odoo.define('mymodule.web.radio.required', function(require){
  var relational_fields = require('web.relational_fields');

  relational_fields.FieldRadio.include({
      isSet: function () {
          return (this.mode === 'edit')? ($(this.$el).find("[checked='true']")).length > 0: this.value;
      },
  });
});

Tags:

Python

Xml

Odoo