Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
4340 Представления

I know that we can create new javascript modules with new widgets, but is there a way to replace functionality of the already existing default form controls? Say, if I wanted that all text fields in the system automatically converted their input to uppercase, could I do this by extending FieldChar? (and not having to modify the actual views in the system, just that my new code overrided the default field)

Аватар
Отменить

One can override default widget, No doubt ... but am not sure whether you can achieve for input data... Alternate option, use Onchange Event...

Автор

Thanks! Yes, it can be done with the onchange event, but the problem is that if I wanted to affect every single field in the system, I would have to extend every single view to add the "onchange" attribute in every single field. Not really an option.

Лучший ответ

Hello,

You can also use python code for this,

_inherit = 'dummy.dummy'
_columns =
    {
        'dummy_field': fields.char('Dummy', size=80, select=True, required=True)
    }
    
def onchange_case(self, cr, uid, ids, dummy_field, context=None):
    result = {
              'value': { 'dummy_field': str(dummy_field).upper() }
    }
    return result

And call oncahnge function in xml.

Thanks.

 

 

 

Аватар
Отменить
Лучший ответ

Julian, yes you can override FieldChar for that purpose.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
сент. 23
2485
0
авг. 20
3142
0
февр. 18
3418
0
сент. 17
4246
2
нояб. 15
726