跳至內容
選單
此問題已被標幟
3 回覆
852 瀏覽次數

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
7243
1
5月 25
1250
2
1月 25
2030
1
1月 25
1491
1
8月 24
1970