Help

3

can i add button to tree view ?

Avatar
Elmasry

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.

Avatar
Discard
3 Answers
1
Best Answer

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>
12 Comments
Avatar
Discard
Avatar
Elmasry
-

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.

Avatar
Pierre Soum
-

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

Avatar
Elmasry
-

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

Avatar
Francesco OpenCode
-

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!

Avatar
Elmasry
-

could you explain more ? please francesco

Avatar
Francesco OpenCode
-

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

Avatar
Elmasry
-

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 :)

Avatar
Francesco OpenCode
-

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?

Avatar
Elmasry
-

yes i can

Avatar
Francesco OpenCode
-

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.

Avatar
Elmasry
-

thx Francesco :)

Avatar
evon_dun
-

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?

0
Best Answer

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

Avatar
Discard
0
Avatar
Diego Calzadilla
Best Answer

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!!

Avatar
Discard