Odoo Help

Welcome!

This community 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.

0

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

By
Alex Garel
on 1/8/14, 12:59 PM 816 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 :

<openerp>
    <data>
        <!-- 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)]'
                   model='ir.ui.view'
                   use='arch'/>
        </record>
        <!-- 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'
                       position="replace">
                </xpath>
                <!-- remove chatter and add custom actions -->
                <xpath expr='//div[@class="oe_chatter"]'
                       position="replace">
                    <footer>
                        <button name="create_child" string="Create" type="object" class="oe_highlight"/>
                         or
                        <button string="Cancel" class="oe_link" special="cancel" />
                    </footer>
                </xpath>
            </field>
        </record>

    </data>
</openerp>

Is that the right way ? Am I missing something ?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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