【问题标题】:Odoo - Change create button textOdoo - 更改创建按钮文本
【发布时间】:2017-09-19 20:53:57
【问题描述】:

我正在使用 Odoo 10e。在我的特定模型的树视图或表单视图中,我想将创建按钮文本更改为Add New User。我们怎样才能做到这一点? 我尝试为此使用 Xpath,但据我所知,Xpath 用于从视图继承并在视图中添加一些内容,而不是更改父视图中的项目

【问题讨论】:

  • 你有没有检查过这样的事情:

标签: openerp odoo-8 odoo-9 odoo-10 odoo-view


【解决方案1】:

创建一个xml文件并在其中写入以下代码。

对于列表视图和表单视图,它将根据您的自定义字符串更改创建按钮的名称。

将此 xml 文件路径添加到清单文件中的 qweb 部分。

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">

<t t-extend="ListView.buttons">
    <t t-jquery=".o_list_button_add" t-operation="replace">    
        <button type="button" class="btn btn-primary btn-sm o_list_button_add" accesskey="c">
            <t t-if="widget.model === 'sale.order'">
                Your String
            </t>
            <t t-if="widget.model !== 'sale.order'">
                <t t-esc="widget.options.addable"/>
            </t>
        </button>
    </t>
</t>

<t t-extend="FormView.buttons">
    <t t-jquery=".o_form_button_create" t-operation="replace">        
        <button t-if="widget.is_action_enabled('create')" type="button"
                class="btn btn-default btn-sm o_form_button_create" accesskey="c">
            <t t-if="widget.model === 'sale.order'">
                 Your String
            </t>
            <t t-if="widget.model !== 'sale.order'">
                 Create
            </t>
        </button>
     </t>
</t>
</templates>

希望这个回答对你有所帮助。

【讨论】:

  • 没有完全工作,但至少我知道了。当我将这些更改添加到单独的文件中时,它不起作用,当我在 base.xml 中添加更改时它起作用。有什么想法吗?
  • 更新了我的答案。现在试试吧。
【解决方案2】:

只需 xpath 到那个按钮。 然后给出位置替换并将字符串更改为从创建添加新用户。 试试这样的代码。 但请记住按钮的名称将保持原样。 谢谢

        <xpath expr="//button[@name='action_set_create']" position="replace">
        <button name="action_set_create" string="Add New User"/>
    </xpath>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    • 2012-05-27
    相关资源
    最近更新 更多