Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
7087 Vistas

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

Use

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

Avatar
Descartar
Autor

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?

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"

@Taher Giyori that's the dumbest thing I've read in a long time

"you give a poor man a fish and you feed him for a day; you teach him to fish... you give him.. you give him.... uhh no no no"

- South Africa news reporter

Mejor respuesta


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
Publicaciones relacionadas Respuestas Vistas Actividad
7
feb 19
13330
4
oct 17
10016
5
jun 20
6442
2
dic 19
2425
0
nov 18
3019