Odoo Help


Is "search + use arch" the right way to derive a form ?

Alex Garel
on 1/8/14, 12:59 PM 1,164 views

I wanted to add a child task creation form. So I wan't this form to have all fields of default task form, but no header, and action to create the child.

So I made a wizard with a osv.Model class with inherit="project.task" and a method returning an action to open a form on a new task with well defined defaults in context. So far, so good.

For the form to use, I did want to use all fields from the task form, so first I inherit base form. That was a mistake, as inheriting, in fact modify the base form. My goal was to have yet another form, not modifying existing one.

So what I did is to get the arch field from original form using the search+model+use attributes on my field :

        <!-- view to add child task, copying default task view -->
        <record id="view_amr_task_add_child_base" model="ir.ui.view">
            <field name="name">amr_project.task.add_child_base</field>
            <field name="model">project.task</field>
            <field eval="16" name="priority"/> <!-- low -->
            <field name="arch"
                   search='[("name", "like", u"project.task.form"), ("inherit_id", "=", None)]'
        <!-- view to add child task -->
        <record id="view_amr_task_add_child" model="ir.ui.view">
            <field name="name">amr_project.task.add_child</field>
            <field name="model">project.task</field>
            <field name="inherit_id" ref="amr_project.view_amr_task_add_child_base" />
            <field name="arch" type="xml">
                <!-- remove header -->
                <xpath expr='//header'
                <!-- remove chatter and add custom actions -->
                <xpath expr='//div[@class="oe_chatter"]'
                        <button name="create_child" string="Create" type="object" class="oe_highlight"/>
                        <button string="Cancel" class="oe_link" special="cancel" />


Is that the right way ? Am I missing something ?

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 1/8/14, 12:59 PM
Seen: 1164 times
Last updated: 3/16/15, 8:10 AM