2017-06-14 219 views
2

如何在Odoo 10窗体视图的右侧栏添加按钮?例如,我在扩展sale.order.form视图具有以下字段:在Odoo窗体视图的右侧栏添加按钮

<xpath expr="//div[@name='carrier_selection']" position="after"> 

    <field name="x_shipping_method_id" options="{'no_create': True, 'no_open': True}"/> 

    <field name="x_shipping_cost"/> 

    <field name="x_staff_notes" attrs="{'invisible': [('x_staff_notes', '=', False)]}"/> 

    <field name="x_custom_products" attrs="{'invisible': [('x_custom_products', '=', False)]}"/> 

    <field name="x_is_custom_products_acknowledged" invisible="1"/> 

    <button name="434" type="action" string="Acknowledge Custom Products" class="oe_highlight" attrs="{'invisible': ['|',('x_custom_products', '=', False),'&amp;',('x_custom_products', '!=', False), ('x_is_custom_products_acknowledged', '=', True)]}"/> 

</xpath> 

这导致与左边的标签,右边的值网格添加新的领域。我希望将按钮元素添加到此网格的右侧列。目前它被放置在标签下方的左侧列中,但我希望它位于右侧列中的值下方。 Odoo可以吗?

这是一个准备好的截图,试图展示我正在努力完成的任务。我只想将按钮放在新的一行中,但是在右列中对齐,并使用上面的值。 enter image description here

+0

见我已经更新了我的答案实现这一目标。 –

回答

2

如果你想只显示值而不是标签,那么你可以做这样的事情,

<field name="x_shipping_cost" nolabel="1" /> 

然后你就可以打印标签

<label for="x_shipping_cost" /> 

通过这种方式你首先打印值,然后标签将打印到右侧。

但是我没有更清楚你想要做什么,所以我只是解释一下你可以做什么来打印左侧的值和右侧的标题。如果您需要其他东西,请澄清。

解决方案:您可以只需添加空标签

<label string=""/> 
<button name="434" type="action" string="Acknowledge Custom Products" class="oe_highlight" attrs="{'invisible': ['|',('x_custom_products', '=', False),'&amp;',('x_custom_products', '!=', False), ('x_is_custom_products_acknowledged', '=', True)]}"/> 
+0

谢谢。我实际上试图在右栏中打印按钮元素。因此,按钮上方的字段应该按正常方式打印,标签在左边,按钮在右边,但是我希望末尾的按钮元素可以在值的右下方打印。那有意义吗?另外,我刚刚意识到我在问题的一部分中已将我的左派和权利颠倒过来。我编辑了这个问题,所以请重新阅读,以确保您的信息正确无误。 – flyingL123

+0

你能举个例子吗?尽可能使用小屏幕截图。 –

+0

我添加了一个截图到原来的问题。这有帮助吗? – flyingL123

相关问题