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

I make a new field in res.user called user_new_option and I want to add this value in the 
XML context  

<record model="ir.actions.act_window" id="model_user_new">
<field name="name">model.user.new</field>
<field name="res_model">model.user.new</field>
<field name="view_mode">tree,form</field>
<field name="context">{'user_new_option': uid}</field>
</record>

how can I do this. 

아바타
취소
베스트 답변

Hi,

Please refer to the code:


<record model="ir.actions.act_window" id="model_user_new">

    <field name="name">model.user.new</field>

    <field name="res_model">model.user.new</field>

    <field name="view_mode">tree,form</field>

    <field name="context">{'user_new_option': user.user_new_option}</field>

</record>



Hope it helps.

아바타
취소
베스트 답변

You can set the default value of field just need to add "default_" before the field like like default_user_new_option.

You can write code like below : 

<record model="ir.actions.act_window" id="model_user_new">
  ​<field name="name">model.user.new</field>
  ​<field name="res_model">model.user.new</field>
​<field name="view_mode">tree,form</field>
  ​<field name="context">{'default_user_new_option': uid}</field> </record> 

아바타
취소
작성자

my friend, I do not want to set a default value, I just want to set the value from field "user_new_option" in the context "user_new_option"
like
user_new_option = self.env.user.user_new_option
how can I do something like this

베스트 답변

How to set a default value for a field when creating a new record using the context?

Here's how it's done:


<record model="ir.actions.act_window" id="model_user_new"> <field name="name">model.user.new</field> <field name="res_model">model.user.new</field> <field name="view_mode">tree,form</field> <field name="context">{'default_user_new_option': 123}</field> </record>

아바타
취소
작성자

I want to get the value from the field in res.user because I want to make it changeable when I change it in the user form It changed in the context

작성자

I mean to get it from the user like self.env.user.user_new_option

관련 게시물 답글 화면 활동
3
7월 25
7242
1
5월 25
1247
2
1월 25
2028
1
1월 25
1488
1
8월 24
1969