Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3 Antwoorden
850 Weergaven

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. 

Avatar
Annuleer
Beste antwoord

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.

Avatar
Annuleer
Beste antwoord

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> 

Avatar
Annuleer
Auteur

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

Beste antwoord

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>

Avatar
Annuleer
Auteur

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

Auteur

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

Gerelateerde posts Antwoorden Weergaven Activiteit
3
jul. 25
7243
1
mei 25
1250
2
jan. 25
2030
1
jan. 25
1491
1
aug. 24
1970