Ajuda

0

[Odoo 10] what is the best way to duplicate an existing view?

Avatar
FEDERICO LEONI

I've added many fields on pos.session with a custom module, and I would like to create a second view.

   <record id="pos_session_tree_adm2" model="ir.ui.view">
<field name="name">pos.divina.custom.tree.view.adm2</field>
<field name="model">pos.session</field>
<field name="arch" type="xml">
<tree string="Sessions" create="0">
<field name="start_at" />
<field name="name" />
<field name="day_sold" />
<field name="day_costs" />
<field name="day_margin" />
<field name="state" />
</tree>
</field>
</record>

<record id = "pos_session_tree_adm2" model = "ir.actions.act_window">
<field name = "name">Sessions</field>
<field name = "type">ir.actions.act_window</field>
<field name = "res_model">pos.session</field>
<field name = "view_type">form</field>
<field name = "view_mode">tree,form</field>
<field name = "view_id" eval= "False"/>
</record>

Problem is the original pos.session tree will be substituted and Odoo will use mine instead (on both places on menu). Then is pretty obvious I'm doing something wrong here.
Since is the first time I need to create a duplicated view I'm a bit confused, what is the best way to archive what I want? 

Avatar
Descartar
2 Respostas
0
Avatar
Taher Giyori
Best Answer

Use

<field name"mode">primary</field>

2 Comentários
Avatar
Descartar
Avatar
FEDERICO LEONI
-

Thanks, but even if the reply is substantially correct and solve completely my issue, you should explain a little mode how primary mode works.

Think if someone less skilled than me will fall in the very sames issue, wouldn't be great to know how your solution works?

Avatar
Taher Giyori
-

True, that's very kind of you.

However, there needs to be some effort from the "someone's" side to to solve their issue. We aren't here to do their homework.

"give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime"

0
Best Answer


Still valid in Odoo 13

You need to use your first view_id in your inherit_id field and use primary mode to duplicate the view rather than override the previous view. Hope this helps anyone looking for more details on how primary mode works.
<record id="NEW VIEW ID" model="ir.ui.view">
<field name="name">NEW VIEW NAME</field>
<field name="model">pos.session</field> <field name="inherit_id" ref="pos_session_tree_adm2"/>       <field name="mode">primary</field>
       <field name="arch" type="xml">
        ...Your modifications
       </field>
</record>
Avatar
Descartar