콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4504 화면

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.

아바타
취소
관련 게시물 답글 화면 활동
0
8월 25
2645
0
8월 20
3351
0
2월 18
3609
0
9월 17
4429
2
11월 15
912