Search code examples
pythonodoopython-3.7odoo-13

How do you show 2 list view of the same field in form view


I already make a form view for a model, in this model, I have a one2many field called task_id that is related to project.task, I tried putting task_id in a page called Details, and Summary both of which is using the same task_id field but have a different view, one has less field to show then the other. but when I tried to make the view, I tried using

<field name="task_id">
  <tree>
     <field name="field_name"/>
  </tree>
</field>

and

<field name="task_id" context="{'tree_view_ref':'module.view_name'}"/>

both field always use the same view everytime. I manage to make the view looks different by adding another field for summary that is related to task_id, but is there a way to have 2 different view, show the same one2many field, in 1 form?


Solution

  • A possible solution is to use a related field:

    other_view_task_id = fields.One2many(related="task_id")
    

    Then add that to your form view:

    <field name="other_task_id" context="{'tree_view_ref':'module.view_name'}"/>