【问题标题】:Odoo 8 - Add button in invoice supplier formOdoo 8 - 在发票供应商表单中添加按钮
【发布时间】:2017-07-25 13:01:05
【问题描述】:

我尝试按照文档说明添加,但当我更新模块时它不起作用。

<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

【问题讨论】:

    标签: inheritance openerp odoo-8 odoo-view


    【解决方案1】:

    您的代码对我来说似乎不错。您可以尝试以下提示。

    • 确保清单文件中给出了 xml 文件名。
    • 活动调试器模式。
    • 从按钮中临时删除 groups="base.group_no_one" 并升级您的模块。

    仅供参考:

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

    type="object"
    

    【讨论】:

    • 确保您已安装模块。有时我们尝试代码但忘记安装模块。这在我身上发生了很多次。
    【解决方案2】:

    使用 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> 
    

    【讨论】:

    • 好的,我认为您遗漏了一些我建议的语法错误,例如 make &lt;field&lt;field1 并查看是否有错误
    • 并在看到按钮时先删除组而不是添加它,因为如果您的用户没有此组,则不会显示按钮
    【解决方案3】:

    只需从该按钮中删除组,然后按钮就会可见。

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

    【讨论】:

      【解决方案4】:

      不要忘记将您的 xml 文件添加到 Odoo 模块清单文件 __openerp__.pydata 下的更新版本 __manifest__.py 喜欢

      {
          '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
          ]
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-05
        • 1970-01-01
        • 1970-01-01
        • 2023-03-29
        • 1970-01-01
        • 1970-01-01
        • 2023-03-05
        • 1970-01-01
        相关资源
        最近更新 更多