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

I'm using odoo 11.

I have a "Course" model with a one2many field "session_id" referencing another "Sessions" model (as in the "building a module" tutorial on the odoo official docs). It all works neatly: when editing a course and adding a session, the wizard pops up and the user can fill the form and save. The only problem is that the "course" field in the wizard form is initially blank, whereas i'd like it to be automatically set equal to the current course.

In other words, I'm trying to make so that if I'm creating a new session from a given course page, the "course" field comes pre-set with the current course. I have no idea on how to accomplish that.

Is there a way to do that? Thank you in advance!


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

Use context in XML (in one2many field).

<field name="external_evaluation_ids" context="{'default_state':state}">
 <tree>
  <field name="state"/> <!--newly created field in one2many table-->
  <field name="child_table_field1"/>
  <field name="child_table_field2"/>
  <field name="child_table_field2"/>
 </tree>
</field>

Reference:

1- http://learnopenerp.blogspot.com/2018/01/get-parent-form-value-in-one2many-form.html

2- https://youtu.be/tx1ONN2e8hk


อวตาร
ละทิ้ง
ผู้เขียน

Thank you very much, this is exactly what i was looking for. It seems to work! Thanks again.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 15
4737
0
ก.พ. 24
701
_rec_name - predefined fields แก้ไขแล้ว
12
เม.ย. 23
55483
0
เม.ย. 18
3549
Ondelete cascade on the inverse comodel แก้ไขแล้ว
1
พ.ค. 23
2234