Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
Why can't I make a button in tree
I want to add a button ,and I rectify the code like this:
<button name="order_confirm" states="draft" string="Confirm Order" icon="gtk-apply" confirm="Are u want to confirm order?"/>
<tree string="Sales Orders" colors="grey:state=='cancel';blue:state in ('waiting_date','manual');red:state in ('invoice_except','shipping_except')">
<field colspan="4" name="name"/>
<field name="date_order"/>
<field name="partner_id"/>
<field name="user_id"/>
<field name="picked_rate" widget="progressbar"/>
<field name="invoiced_rate" widget="progressbar"/>
<field name="amount_untaxed" sum="Total Tax Excluded"/>
<field name="amount_total" sum="Total Tax Included"/>
<field name="state"/>
</tree>
But it cant work ,I want to know what mistake i make... Thanks...
As previous answers said, this is not possible (that I'm aware of!). You can either put the button in the tree lines, but this will create a different button for every line of the tree or you can create a server action that can be triggered from the 'More' menu on the top using as argument the selected rows.
For doing the later, you do it like:
<record id="id_for_the_action" model="ir.actions.server">
<field name="name">The Name of the Action</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_your_model"/>
<field name="state">code</field>
<field name="code>self.function_to_run(cr, uid, context.get('active_ids'), context=context)</field>
</record>
<record id="id_of_the_action_value" model="ir.values">
<field name="name">Name for action value</field>
<field name="action_id" ref="id_for_the_action"/>
<field name="value" eval="'ir.actions.server,' + str(ref('id_for_the_action'))"/>
<field name="key">action</field>
<field name="model_id" ref="model_your_model"/>
<field name="model">your_model</field>
<field name="key2">client_action_multi</field>
</record>
Be aware that when putting model_id
you need to put model_your_model
with the model_
part included and _
instead of .
Hope this suits you!
I write " <field name="model_id" ref="model_sale_order"/> <field name="code">action_button_confirm(context=context)</field>" like this,and it installed success. it also has a trigger in "More"... but there is a new error here: NameError: name 'action_button_confirm' is not defined... i do not know where should i defined it ..
Sorry, my bad, I forgot to put it the right way, you have to put 'self.function_to_run'. I updated my answer.
You should put the <button>
tag within the <tree>
tag.
yeah..i try it ...but it also failure...I want it in the top of the tree ..it just add a icon in the list, .it look like: http://postimg.org/image/pacx2hm0f/
You mean next to "Create" and "Delete"? I do not think that this is possible.
maybe not next to "Create" and "Delete",can be in anywhere, i just want that i can "confirm sale" with many quotations ...
Then you have to use a separate window_action or wizard to perform a certain action on several resources.
I write like this
<record id="action_sale_order_confirm_sales" model="ir.actions.server">
<field name="name">Confirm sale1</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_sale_order"/>
<field name="state">code</field>
<field name="code">action_button_confirm(context=context)</field>
</record>
<record id="id_of_the_action_value" model="ir.values">
<field name="name">Confirm sale1</field>
<field name="action_id" ref="action_sale_order_confirm_sales"/>
<field name="value" eval="'ir.actions.server,' + str(ref('action_sale_order_confirm_sales'))"/>
<field name="key">action</field>
<field name="model_id" ref="model_sale_order"/>
<field name="model">sale.order</field>
<field name="key2">client_action_multi</field>
</record>
and "def action_button_confirm" is in sale.py/class sale_order....
but there is a new error here: NameError: name 'action_button_confirm' is not defined... and i do not know where should i defined it ...
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.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 3/22/13, 3:47 AM |
Seen: 3818 times |
Last updated: 9/18/15, 5:40 AM |
it woke like this : http://postimg.org/image/x3xmfw18j/