Mohamed Yousof
Mohamed Yousof

Reputation: 775

treeview with select option, to add selected in odoo

I need to create a popup treeview like the one in picture below, and then can select as many items as I need to be inserted to the original tree-view

enter image description here

Upvotes: 0

Views: 5247

Answers (2)

Charif DZ
Charif DZ

Reputation: 14721

if your field is a one2many field from what i understand your field must be a one2many field because in one2many field when you click on add item it send you direclty to a create popup in order to change this behavor you need to change the widget of this field like this :

<field name="you_o2m_field_name" widget="many2many" >
  <tree>
     <field name="field_name1"/>
     <field name="field_name1"/>
     <field name="field_name1"/>
  </tree>
<form>
  <!-- you can put a costum form view also  here -->
</form>
</field>

but you i think you need to give it an option not_delete like this

<field name="you_o2m_field_name" widget="many2many" options="{'not_delete':True}"/>

because when you remove the record from the tree one2many delete it from the table if you want to keep it then use no_delete option

define a search view for the model exam

<record id="id_for_this_view_here" model="ir.ui.view">
            <field name="model">model.name</field>
            <field name="arch" type="xml">
                <search string="recherche" >
                    <field name="field_name" />
                    <field name="field_name"/>
                </search>
            </field>
        </record>

the frame work will create a search view for you if you don't specify one for your model this why the search have only create by ok so whenever you have a search view with create by you need to define a _rec_name for your model or create a search view

Upvotes: 0

Tessnim
Tessnim

Reputation: 453

If you want it to give you a popup containing a tree view where you can choose from the list. You need to have a many2many relation between the 2 modules, it seems like you have one2many relation.

Upvotes: 1

Related Questions