【问题标题】:Customize "Add an Item" in Openerp在 Openerp 中自定义“添加项目”
【发布时间】:2014-11-18 05:29:49
【问题描述】:

我需要在树形视图中更改“添加项目”的名称。无需在基类中对其进行编辑。

从“web/static/src/js/view_form.js”触发添加项目。

那么如何将名称“添加项目”更改为“添加”

 var $cell = $('<td>', {
        colspan: columns,
        'class': this._add_row_class || ''
    }).append(
        $('<a>', {href: '#'}).text(_t("Add an item"))
            .mousedown(function () {
                // FIXME: needs to be an official API somehow
                if (self.view.editor.is_editing()) {
                    self.view.__ignore_blur = true;
                }
            })

或者创建一个新的 js 文件,以及如何反映在我的项目中

【问题讨论】:

    标签: openerp openerp-7 odoo


    【解决方案1】:
    (function () {
        "use strict";
        openerp.web.form.AddAnItemList.include({
            pad_table_to : function() {
                var self = this;
                this._super.apply(this, arguments);
                //for one2may field
                self.$current.find('.oe_form_field_one2many_list_row_add a').text('Your Text');
                //for many2many field
                self.$current.find('.oe_form_field_many2many_list_row_add a').text('Your Text');
            }  
        });
    }) ();
    

    把上面的代码放在你的js文件中,我想你可以在你的js文件中访问openerp实例,希望对你有帮助:)

    【讨论】:

    • 抱歉 Jigs,它不起作用,我在现有模块中添加了一个新的 js 文件,并在 openerp.py 中添加了依赖项,但没有骰子。
    • 我已经更新了代码位,使其成为匿名函数,现在它应该可以工作了,我想你的 js 只包含这个代码。
    猜你喜欢
    • 2014-03-17
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 2017-11-18
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多