This question has been flagged
4 Replies
2610 Views

I've added a second Purchase Orders view in my left-side menu. The first Purchase Orders view is the default one bundled in Odoo 8. The second Purchase Orders view should have different columns. This is the xml of the second view:

<record id="view_purchase_order_with_core_product" model="ir.ui.view">
<field
name="name">my.custom.PO.view</field>
<field
name="model">purchase.order</field>
<field
name="type">tree</field>
<field
name="priority">1</field>
<field
name="arch" type="xml">
<tree>
<field
name="product_id"/>
<field
name="message_unread"/>
</tree>
</field>
</record>

<record
id="act_purchase_order_with_core_product" model="ir.actions.act_window">
<field
name="name">Second PO view</field>
<field
name="type">ir.actions.act_window</field>
<field
name="res_model">purchase.order</field>
<field
name="view_mode">tree,form</field>
<field
name="context">{}</field>
<field
name="domain">[('has_core_articles', '=', True)]</field>
<field
name="view_id" ref="view_purchase_order_with_core_product"/>
</record>


<menuitem id="menu_purchase_order_with_core_product" name="Second PO view"
parent="purchase.menu_procurement_management"
action="act_purchase_order_with_core_product" sequence="14"/>

The purpose of that second view is to display only orders which contains certain articles, display differents columns than the original view.

I've managed to do the filter using the domain field (I didn't want to use the search filter for that).

My problem is that when I modify the columns of my second views, the original view (the first view) is also modified and display the extra columns.

What am I doing wrong ?


EDIT: I've removed the priority field but I still have the same error after upgrading my module

Avatar
Discard
Best Answer

Hi,

Can you remove the below line from the code and check the same:-     <field name="priority">1</field>

<record id="view_purchase_order_with_core_product" model="ir.ui.view">
<field name="name">my.custom.PO.view</field>
<field name="model">purchase.order</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree>
<field name="product_id"/>
<field name="message_unread"/>
</tree>
</field>
</record>

Thanks

Avatar
Discard
Author Best Answer

Thanks guys for the answers, I've removed the priority field, modified the name of the view and updated the module in my Odoo instance. However I still see the product_id and the message_unread columns in both PO views instead of just the second one. The name of the second view has been impacted as expected though.

What's strange to me is that I didn't inherit the original PO view so I don't understand how my changes on my second view is even impacting the original PO view. Is the view deduced from the model itself ?

I did try to inherit from the original PO view also, but I end up with the same results: changes in my second view are impacted in the original PO view as well...


EDIT: restarting my Odoo instance + updating the installed module didn't seem to change anything but I've retried with a brand new DB and it works as expected !

To prevent myself from running from this kind of error in the future, is there a foolproof method to update an installed module without having to restart everything from a clean DB ?

Avatar
Discard
Best Answer

Hello Paraita,

You have done well but the mistake is priority, so remove priority and then upgrade it will work.

<field name="priority">1</field>
Avatar
Discard

We have mentioned the same in the above answer.