Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2759 มุมมอง

I have a model that shows a form view but whenever I click that item a new record will be created instead of showing the earlier created record. I have tried adding this:

{'form_view_initial_mode': 'view', 'default_res_id': 'hotel.getdates,get_first_record_id()'}

but didn't work... This is my XML:


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Instead of 'default_res_id': 'hotel.getdates,get_first_record_id()', you should use Python code to dynamically retrieve the ID of the first record. Assuming you have a function somewhere called get_first_record_id() that returns the id of the first record, you should pass it like this:

<record id="open_hotel_get_dates_tree" model="ir.actions.act_window">
    <field name="name">Get Calendar Files</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hotel.getdates</field>
    <field name="view_mode">form</field>
<field name="context">{'form_view_initial_mode': 'view', 'default_res_id': get_first_record_id()}</field>
</record>


Hope it helps

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 24
2651
0
ก.พ. 22
2004
6
ส.ค. 19
10173
Difference in Record and Recordsets? แก้ไขแล้ว
5
ก.พ. 19
10332
0
ก.พ. 23
2204