Skip to Content
Menu
This question has been flagged
2 Replies
18056 Views

Hi everyone,

I'm using Odoo 10 and try to customize the applicant form. I add the new model to Odoo, and change the Applicant model with adding a new fields:

comment_ids : one2many

And I update the Applicant form view by adding information of "Comment" object:

<field name="x_comment_ids">

    <tree>

        <field name="x_name"/>

        <field name="x_applicant_id"/>

    </tree>

</field>

Now, the comment display per applicant is correct, .

But, If I "Add new item" for "comment" from applicant form, I have to select the applicant from the list.

So, is there anyway to pass the current applicant to the new comment form, and I don't have to select it again?


Thank you

Avatar
Discard
Best Answer

Dear Vu,

You may use the default_FIELDNAME in the context on the one2many field x_comment_ids.

context="{'default_x_name': name}"
Avatar
Discard
Best Answer

If you wan to get parent form field value into one2many than its possible using context. To get parent value in one2many we may use context in XML.

<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> 

In above code snippet we have one2many field and in that field we define context with key value. Here name of key will starts from "default_" and than the field name, the value should be the parent table field name which we want to display in one2many pop up form view.

Read more about context in detail: http://learnopenerp.blogspot.com/2018/01/get-parent-form-value-in-one2many-form.html

Avatar
Discard