2017-07-25 29 views
0

我尝试添加文档说的内容,当我更新模块时,它不起作用。Odoo 8 - 在发票供应商表单中添加按钮

<record id="some_example_id" model="ir.ui.view"> 
    <field name="name">example.name</field> 
    <field name="model">account.invoice</field> 
    <field name="inherit_id" ref="account.invoice_supplier_form" /> 
    <field name="arch" type="xml"> 
     <data> 
      <button name="invoice_cancel" position="after"> 
       <button name="test_button" states="draft,proforma2,open" string="test" groups="base.group_no_one" class="oe_highlight"/> 
      </button> 
     </data> 
    </field> 
</record> 

Exactly here

回答

0

你的代码似乎对我好。您可以尝试以下提示。

  • 确保在清单文件中给出xml文件名。
  • 主动调试器模式。
  • 临时删除groups =“base.group_no_one” from button并升级您的模块。

只是为了一张纸条:

你的按钮将调用工作流程,因为你没有给属性按钮。如果你想直接调用python函数,那么我们需要在按钮中添加属性,如

type="object" 
+0

试过,但仍不能工作。 – drkpkg

+0

确保你已经安装了模块。有时我们尝试代码,但忘记安装模块。这发生了很多次。 –

0

使用xpath表达式来定位并放置元素。

<record id="some_example_id" model="ir.ui.view"> 
     <field name="name">example.name</field> 
     <field name="model">account.invoice</field> 
     <field name="inherit_id" ref="account.invoice_supplier_form" /> 
     <field name="arch" type="xml"> 
       <!-- using xpath target the element that you want to put button inside 
        or after or before ex: header --> 
       <xpath expr="//header" position="inside"> 
        <button name="test_button" states="draft,proforma2,open" string="test" groups="base.group_no_one" class="oe_highlight"/> 
       </xpath> 
     </field> 
    </record> 
+0

通过xpath尝试了很多次,我没有解决方案:( – drkpkg

+0

好吧,我认为你错过了一些东西,我建议是做一个语法错误,像make < Cherif

+0

并且在看到该按钮时首先删除该组,而不是添加它,因为如果用户没有该组,则该按钮将不会显示 – Cherif

0

刚刚从该按钮删除组按钮,然后将可见。

<button name="invoice_cancel" position="after"> 
    <button name="test_button" states="draft,proforma2,open" string="test" class="oe_highlight"/> 
</button> 
0

不要忘了你的XML文件添加到Odoo模块清单文件__openerp__.py__manifest__.py更新版本data下像

{ 
    'author': 'me', 
    'name': 'My Module', 
    'depends': [base], 
    # and so on 
    'data': [ 
     'my/path/to/my/views.xml', 
     'views/account_invoice_views.xml' # as in the odoo guideline 
    ] 
}