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.

3

can i add button to tree view ?

By
Elmasry
on 3/26/13, 7:13 AM 14,547 views

Hi, All

simply i want to add a button on hr employee tree view but i cant do it .. i tried to add it through header tag but seem it is not available.

anyone can help me please?!!

This is my code

<record id="view_employee_tree" model="ir.ui.view">
            <field name="name">hr.employee.tree</field>
            <field name="model">hr.employee</field>
            <field name="arch" type="xml">
                <tree string="Employees">
                    <header>
                    <button name="confirm" string="Confirm" class="oe_highlight"/>
                    </header>
                    <field name="name"/>
                    <field name="work_phone"/>
                    <field name="work_email"/>
                    <field name="company_id" groups="base.group_multi_company"/>
                    <field name="department_id"/>
                    <field name="job_id"/>
                    <field name="parent_id"/>
                    <field name="coach_id" invisible="1"/>
                </tree>
            </field>      
        </record>

Error is : ... ERROR database openerp.addons.base.ir.ir_ui_view: <string>:1:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMWRONG: Did not expect element header there ... ERROR database openerp.addons.base.ir.ir_ui_view: <string>:2:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element tree has extra content: header

Thanks in advance.

2

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 3/26/13, 7:16 AM

Tree view hasn't header section. Insert the button like a normal field.

<record id="view_employee_tree" model="ir.ui.view">
            <field name="name">hr.employee.tree</field>
            <field name="model">hr.employee</field>
            <field name="arch" type="xml">
                <tree string="Employees">
                    <button name="confirm" string="Confirm" class="oe_highlight"/>
                    <field name="name"/>
                    <field name="work_phone"/>
                    <field name="work_email"/>
                    <field name="company_id" groups="base.group_multi_company"/>
                    <field name="department_id"/>
                    <field name="job_id"/>
                    <field name="parent_id"/>
                    <field name="coach_id" invisible="1"/>
                </tree>
            </field>      
        </record>

thank you very much Francesco it is work now

but didn't give me the result that i want

i want to add this button out of the tree grid like from view . but what actually happened that the button repeated with every row of data .

have you any advice for me.

Elmasry
on 3/26/13, 8:17 AM

Yes the tree view is often missing and would be a GREAT fonctionnality...

Cogitae, Pierre Soum
on 3/26/13, 8:27 AM

But what can i do to add button above or under tree view???

Elmasry
on 3/26/13, 8:38 AM

If you create a wizard that call the some function of the button, you can find a menu voice in the "Other" menu at top of tree that does what you want!

Francesco OpenCode
on 3/26/13, 8:48 AM

could you explain more ? please francesco

Elmasry
on 3/26/13, 9:05 AM

Create a wizard, insert in it a button similar to button you want "copy". In tree you can select the record that you want confirm, go to Other menu and select the wizard you have created. Click on the button in wizard (your button) and it confirm the records

Francesco OpenCode
on 3/26/13, 10:12 AM

i did what as you told me and write the code to create wizard and add the button to it

but what is "Other" menu .. do you mean "More" menu if u mean "More " so i can't find it's code sorry Francesco but i really need it.

thanks for helping me your answer helped me but hope more :)

Elmasry
on 3/26/13, 11:58 AM

Excuse me but I'm italian and I use italian location in my db so I sometimes forgot original name of Menu...:)....Do you know how to create an openerp module?

Francesco OpenCode
on 3/26/13, 12:17 PM

yes i can

Elmasry
on 3/27/13, 5:37 AM

Ok, so isn't difficult to create a wizard. In this wizard you insert a button that calla a funtion egual to function called by confirm button. It's all.

Francesco OpenCode
on 3/27/13, 6:00 AM

thx Francesco :)

Elmasry
on 3/28/13, 6:32 AM

want to know about a button on invoice view when we select few records to get reports printed, can we have a button there to call a function and then select invoices to print?

evon_dun
on 7/17/13, 4:42 AM
0

Elmasry Hi, I have the same problem as you, perhaps a little later, but let me know if you solved your problem

0
Diego Calzadilla
On 10/11/13, 1:01 AM

Maybe it's too late but you should try something likes this:

       <form string="Product form view" version="7.0">
               <!--   <field name="qtty"/>-->
                <field name="products" widget='many2many_list' context="{'tree_view_ref':'_new_tree.product_product_tree'}">
                    <tree string="Products" >
                <!-- <field name="default_code"/>-->
                <field name="name"/>
               <!--  <field name="categ_id" invisible="1"/>
                <field name="type" invisible="1"/>
                <field name="variants" groups="product.group_product_variant"/>
                <field name="uom_id" string="Unit of Measure" groups="product.group_uom"/>-->
                <field name="qtty"/>
               <field name="qty_available"/>
                <field name="virtual_available"/>
                <field name="lst_price"/>
                <field name="price" invisible="not context.get('pricelist',False)"/>
                <field name="standard_price" invisible="1"/>
                <field name="state"/>
                <field name="company_id" groups="base.group_multi_company" invisible="1"/>
            </tree> 
                </field>
                <footer>
                    <button string="Cancel" class="oe_link" special="cancel"/>
                     or
                    <button name="make_order" type="object" string="Generate Order" class="oe_highlight"/>
                </footer>

It's just a tree inside a form , after the tree you add the buttons!!

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: 3/26/13, 7:13 AM
Seen: 14547 times
Last updated: 3/16/15, 8:10 AM