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.

0

[V8] Is there a way to have two buttons on the same position on a tree view (not at the same time)?

By
FEDERICO LEONI
on 6/17/15, 7:27 PM 686 views

As subject. I have two buttons that disappears when the other is active. Is there a way to have it on the same row?

As far as I know Odoo smart buttons can't do that...

Edit: Here is my xml source code:

<openerp>
<data>
<record id= "Kitchen_orders_tree_view" model= "ir.ui.view">
<field name= "name">Kitchen_orders_tree</field>
<field name= "model">rest.order</field>
<field name= "field_parent" eval="False"/>
<field name= "arch" type= "xml">
<tree string = "Pedidos da Cozinha" colors="red:to_wait=='Sim'" create="false">
<field name= "date_order" on_change="on_change_kot_time(date_order,end_date)"/>
<field name = "partner_name"/>
<field name = "qty"/>
<field name = "product_name"/>
<field name = "instructions"/>
<field name= "end_date" on_change="on_change_kot_time(date_order,end_date)"/>
<field name = "to_wait" invisible = "1"/>
<field name= "minutes" on_change="on_change_kot_time(date_order,end_date)"/>
<field name = "status" />
<button name="642" string="Avançar" type="action" attrs="{'invisible':[('to_wait','=','Não')]}" />
<button name="638" string="Enviar" type="action" attrs="{'invisible':['|', ('status','=','Pronto'), ('to_wait','=','Sim')]}" />

</tree>
</field>
</record>
<record model= "ir.actions.act_window" id= "kitchen_orders">
<field name= "name">kitchen_orders_action</field>
<field name= "type">ir.actions.act_window</field>
<field name= "res_model">rest.order</field>
<field name= "view_type">form</field>
<field name= "view_mode">tree</field>
<field name= "view_id" eval="False"/>
<field name= "domain">[]</field>
</record>
<menuitem
action= "kitchen_orders"
id= "kitchen_order_menu"
parent= "point_of_sale.menu_point_of_sale"
name= "Restaurant"
sequence= "10"/>
</data>
</openerp>

2

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 6/26/15, 4:21 AM

No, they will always be in two columns.. 
but workaround could be ONE button (type=object) , calling one method (instead of two buttons for two actions!)

and in method you can decide based on some data will you trigger (return)  action_1 or action_2   ...

hope it helps a bit..

Interesting solution. Could you please elaborate more? Do you have a link to have a look on it? Thanks.

FEDERICO LEONI
on 6/26/15, 8:24 AM

This is a bit hard to evaluate... my guess is that this part of view xml is not from source xml, looks more like you just copy/pate it from edit view wizard ... to elaborate more on this idea a quick look at whole module ( py & xml file) would be of help... maybe if your code is somewhere public availabel i could take a look at the module ?

Bole
on 6/26/15, 11:10 AM

I've added my xml source. On the .py there is just the creation of the table.

FEDERICO LEONI
on 6/27/15, 1:58 PM
1
Yogesh
On 6/27/15, 10:26 PM

You can change button label to "Avançar / Enviar" then call a method on that button. before you make any action first you check state of your record (you already have some field to distinguish that is used to change color to "Red /Black" ). if your record is in state which is making it black you write code which is written in "Enviar" button if your record is in state which is making it Red you can method which is written on button "Avançar".

f you don't want to label button like "Avançar / Enviar" but only "Avançar"  or  "Enviar" then you write fields_view_get() and change label of button based on State of record.





Hope that helps you :)

Know that there are solutions helps for sure but... fields_view_get() seems to be really complicated to use. In python I can do that in 2 minutes with if/elif. Anyway, I'll have a better look on it. Thanks.

FEDERICO LEONI
on 6/28/15, 8:57 AM

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

1 follower(s)

Stats

Asked: 6/17/15, 7:27 PM
Seen: 686 times
Last updated: 7/1/15, 8:17 AM