Skip to Content
Menu
This question has been flagged
5 Replies
6755 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>

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

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 ?

Author

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

Best Answer

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

Avatar
Discard
Author

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.

Related Posts Replies Views Activity
0
Jun 15
120
0
Jul 15
2763
1
Jun 15
5321
1
Mar 15
3001
2
Jul 15
5724