Odoo Help

1

2
3 Answers
4
Avatar

Lucio Argentina

--Lucio--

901
| 6 5 9
Buenos Aires, Argentina
--Lucio--
Karma will give me a place in heaven!
Lucio Argentina
3/22/13, 8:45 AM

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!

2 Comments
CK China
3/24/13, 11:00 PM

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

Lucio Argentina
3/25/13, 8:31 AM

Sorry, my bad, I forgot to put it the right way, you have to put 'self.function_to_run'. I updated my answer.

2
Avatar

Andreas Brueckl Austria

--Andreas Brueckl--

5546
| 8 8 9
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl Austria
3/22/13, 4:39 AM

You should put the <button> tag within the <tree> tag.

4 Comments
CK China
3/22/13, 4:44 AM

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/

Andreas Brueckl Austria
3/22/13, 5:07 AM

You mean next to "Create" and "Delete"? I do not think that this is possible.

CK China
3/22/13, 5:28 AM

maybe not next to "Create" and "Delete",can be in anywhere, i just want that i can "confirm sale" with many quotations ...

Andreas Brueckl Austria
3/22/13, 6:53 AM

Then you have to use a separate window_action or wizard to perform a certain action on several resources.

0
CK China
3/24/13, 11:10 PM

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

4 Comments
CK China
3/24/13, 11:16 PM

i know the problem ...i should write like this : <field name="code">obj.action_button_confirm(context=context)</field>

Lucio Argentina
3/25/13, 8:33 AM

Did not saw this before and changed my answer! :D

CK China
3/26/13, 2:13 AM

Anyway,thank you so much~:D

kaynis
8/5/13, 2:21 PM

Hi CK, I am having the same issue can you please help with the python and xml codes that works correctly for you? Thank you

Ask a Question
Writer
100
CK
Tag
Keep Informed
0 follower(s)
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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now