İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
7913 Görünümler

Hi everyone , thank you very much for your help and support . I have started my first module with odoo 11 but i am facing a problem. Please forgive my poor level in english , i am doing my best.So, here is my problem: I have created two models : let 's say model 1 and model 2.In the xml tree view of model 1 , for each record line i added a button "pay now" . what i want is that when i click on the "pay now" button (on model1 tree view) it opens a form of model 2 (in a popup window) with the defaults values filled by some informations providing by model 1 's line selected on tree view.

here is my tree view ....

let s  take these fields names as examples:

field1            |          field2           |         field3    |   field4          |  field5


the button code for the tree view is

<tree>
<button
name="%(custom_action_id)d" string="Pay now" class="oe_highlight" type="action"/>
</tree>

the action code called by the button is

 <record id="custom_action_id" model="ir.actions.act_window">
<field
name="name">list examples</field>
<field
name="res_model">model2.name</field>
<field
name="src_model">model2.name</field>
<field
name="view_type">form</field>
<field
name="view_mode">form</field>
<field
name="target">new</field>
</record>

what i want is that if i click on pay now the model2 form opens ,having by default the fields filled by values of the line selected on tree view.

here is an example of the form called:

                         field5                                                              field6


remark: field6's value should be equal to field2 's value and field5's value should be equal to field1's value . Field5 's type is Many2one while field1's type (which will provide field5's value) is a char type.

Once again thank you to anyone who will take the time to read my post.

best regards


Avatar
Vazgeç
Üretici En İyi Yanıt

Hi , i found the solution .

in the tree view of model 1 , i have used the context attribute on the button to define my default values.

eg :

<button name"%(target_action)d string="Pay now" type="action" context="{'param1': active_id,'param2':field2}"/>

and in the record action

<field name="context">{'default_field5_name': context.get('param1', False),'default_field6_name': context.get('param2', False),}</field>
Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
8
Eki 21
11628
3
Şub 18
7164
0
Ağu 18
4927
2
Tem 18
10134
0
Haz 15
3806