fields_view_get builds a generic view although an inherited view is available

Bug #1302134 reported by Olivier Laurent (Acsone)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Opinion
Wishlist
OpenERP's Framework R&D

Bug Description

When no view is defined on a model, the "fields_view_get" method builds a generic view (displaying for instance for a form all fields of the model on 2 columns without any other design consideration).
Unfortunately this behavior of "fields_view_get" may also occur although a view is well defined on the model.
It is the case when the expected view is inherited from a view of another model, typically an abstract model.

To reproduce, define a model like this:
class my_partner_category(orm.Model):

    _name = 'my.partner.category'
    _inherit = ['res.partner.category']

    _columns = {
        'my_field': fields.char(string='My Field'),
    }

... a view, an action and a menu like this:
        <record id="view_my_partner_category_form" model="ir.ui.view">
            <field name="name">res.my.partner.category.form</field>
            <field name="model">my.partner.category</field>
            <field name="inherit_id" ref="base.view_partner_category_form" />
            <field name="arch" type="xml">

                <xpath expr="//field[@name='name']" position="after">
                    <field name="my_field" />
                </xpath>

            </field>
        </record>

        <record id="my_partner_category_action" model="ir.actions.act_window">
            <field name="name">MPC</field>
            <field name="res_model">my.partner.category</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuitem id="my_partner_category_menu" action="my_partner_category_action" />

Click on the MPC menu then Create => a generic view not inherited from base.view_partner_category_form is displayed...

Many thanks to fix this issue on [7.0] official branch.

A MP on [7.0] follows.

Related branches

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hi,

This is actually the expected behavior. Constructing the main view by inheriting one from another model is a (rather undocumented) technique to spare the view duplication in some rare cases. We prefer to force the developer to make this decision explicit by setting the corresponding view_id in the actions where it is relevant, so it won't happen accidentally.

The alternative is likely to introduce random surprises when developers fail to properly care about the priority of their inherited views (which used to be irrelevant).

We could reconsider this if a new and more explicit way to define foreign-view inheritance was introduced, but not with the current "hackish" technique. I hope you understand.

Thanks,

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Opinion
summary: - [7.0][saas-2]: fields_view_get builds a generic view although a real
- view is available
+ fields_view_get builds a generic view although an inherited view is
+ available
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.