This question has been flagged
4 Replies
73146 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.

Avatar
Discard
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>
Avatar
Discard
Author

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.

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

Author

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

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!

Author

could you explain more ? please francesco

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

Author

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

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?

Author

yes i can

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.

Author

thx Francesco :)

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?

Best Answer

Hi,

In the latest versions, it can be easily achieved as we do in form.

See:  https://www.youtube.com/watch?v=R8eG6uOxHKw

Thanks

Avatar
Discard
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
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