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

Hi,

In the base Parter model we have the following field:

lang = fields.Selection(_lang_get, string='Language', default=lambda self: self.env.lang, help="All the emails and documents sent to this contact will be translated in this language.")

I want to change the default value of this field to 'da_DK'  in my inherited model and the code is

lang = fields.Selection(string='Lang', default='da_DK')
But it's not working. Can anyone please suggest me the workaround? The default value should get selected when the form view is loaded for the customer.

Thank you for your help in advance! :)
아바타
취소

Why not implement this as an IR.DEFAULT record? This is the way we do it when you install a second language (by making English the default). IR.DEFAULT records are migrated for you at each release, so you have no code to write or maintain.

작성자

Thanks, Ray. Agree with you, we can handle it that way as well. But can you please help to figure out the problem with the above code lines?

베스트 답변

Hey lang field is working on the _lang_get function which fetches list of languages from res.lang module. While in your custom field you are not doing that and your selection field contains nothing. I suggest two things if you want some hard coded values in your field then try making a simple selection field or else uses Many2one field with a selection widget or you may try using  same function in your code and try setting default value for that

아바타
취소
관련 게시물 답글 화면 활동
3
5월 25
1748
1
11월 24
1381
2
3월 24
1989
1
6월 23
2287
1
4월 23
2724