Freddy
Freddy

Reputation: 876

Odoo Inherited view not styled

i want to inherit one view from another in Odoo v8. The first view has the id: form_authority_information and the inherited view has the id: form_authority_information_construction_law

Here's the code for form_authority_information

<record model="ir.ui.view" id="form_authority_information">
        <field name="name">view.name</field>
        <field name="model">company.authority_information</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <group colspan="4" id="content">
                        <group colspan="2" col="2" id="general">
                            <separator string="General" colspan="2"/>
                            <field name="related_field"/>
                            <field name="information_date"/>
                            <field name="information_medium" attrs="{'invisible':[('is_finished', '=', True)]}" />
                            <field name="is_finished"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

Correct formatting in master view

And for form_authority_information_construction_law:

<record model="ir.ui.view" id="form_authority_information_construction_law">
        <field name="name">Construction Law</field>
        <field name="model">company.authority_information.construction_law</field>
        <field name="inherit_id" ref="form_authority_information"/>
        <field name="arch" type="xml">
            <data>
                <group id="general" position="after">
                    <separator string="Construction Law" colspan="2"/>
                    <field name="construction_law_type"/>
                    <field name="building_area_type"/>
                    <field name="zoning_name" attrs="{'invisible':[('construction_law_type', '=', 'qualified')]}"/>

                </group>
            </data>
        </field>
    </record>

Wrong formatting in inherited view

The data inheritance works fine. I have all the fields i want to see in the inherited view. The problem is, that it does not style the inherited view. For the master view everything is displayed in a "sheet"-environment but for the inherited view the order is another and the sheet is not displayed. Also the "attr" property doesn't work.

Does anyone know the solution for this strange behaviour?

Update: Images Update2: Is an external id necessary to work properly?

Update3: Python code models.py

class company_authority_information(models.Model):
    _name = 'company.authority_information'
    # other fields...

class company_authority_information_report_committee(models.Model):
    _name = 'company.authority_information.report_committee'
    _inherit = 'company.authority_information'

Thanks in advance.

Upvotes: 0

Views: 1526

Answers (1)

Try following,

class company_authority_information(models.Model):
    _name = 'company.authority_information'
    # other fields...

class gut8_authority_information_report_committee(models.Model):
    _inherit = 'company.authority_information'

If you provide _name then it will create table for that, so when you inherit any model then either you keep the same _name as _inherit or do not specify _name in case of _inherit exist there. restart server and upgrade module if not work.

<record model="ir.ui.view" id="form_authority_information_construction_law">
        <field name="name">Construction Law</field>
        <field name="model">company.authority_information</field>
        <field name="priority" eval="50" />
        <field name="inherit_id" ref="form_authority_information"/>
        <field name="arch" type="xml">
                <group id="general" position="after">
                    <separator string="Construction Law" colspan="2"/>
                    <field name="construction_law_type"/>
                    <field name="building_area_type"/>
                    <field name="zoning_name" attrs="{'invisible':[('construction_law_type', '=', 'qualified')]}"/>
                </group>
        </field>
    </record>

Upvotes: 1

Related Questions