Openerp 更改文本';添加一项';在树状视图中,odoo 9
如何在自定义模块中将文本“添加项”更改为“添加新行”Openerp 更改文本';添加一项';在树状视图中,odoo 9,openerp,odoo-9,Openerp,Odoo 9,如何在自定义模块中将文本“添加项”更改为“添加新行” 任何简单的解决方案?此字符串由提供。因此,您必须扩展js小部件以更改名称。Hello指针, 使用odoo 8 试试下面的代码 您的\u模块\u名称/view/custome\u文件\u include.xml 您的\u模块\u名称/src/js/custome\u视图\u form.js 模块名称->视图->文件名称.xml 现在我们在BaseOdoo9模块中添加CustomeJS,因此我们创建xml文件并继承基本文件,然后添加Custome
任何简单的解决方案?此字符串由提供。因此,您必须扩展js小部件以更改名称。Hello指针, 使用odoo 8 试试下面的代码 您的\u模块\u名称/view/custome\u文件\u include.xml 您的\u模块\u名称/src/js/custome\u视图\u form.js 模块名称->视图->文件名称.xml
现在我们在BaseOdoo9模块中添加CustomeJS,因此我们创建xml文件并继承基本文件,然后添加CustomeJS odoo_v9->web->static->src->js->views->form_relationship\u widget.js 将X2ManyList:X2ManyList这一行添加到基本js(odoo9模块)表单_relation_widget.js中
return {
FieldMany2ManyTags: FieldMany2ManyTags,
AbstractManyField: AbstractManyField,
X2ManyList : X2ManyList, ////Add this line in this file
};
我希望我的回答是有帮助的。
如果有任何查询,请发表评论。您可以选择进入调试模式 然后,进入配置->应用术语->同步术语。在下拉语言中,选择英语并等待完成 转到翻译术语,在搜索字段中填写“添加项目”,并替换翻译值列中的文本
值得一提的是,此更改将存储在数据库中,所有one2many关系都将受到影响。Tnx需要帮助,我复制了您的代码,但文本没有更改!此模块在odoo 8中创建。我成功运行了此确定,我将在更新问题后尽快在odoo 9中创建…Thanx
openerp.fm_sale_order_ext_ept = function(instance) {
change_tree_view_add_item_name(instance);
}
function change_tree_view_add_item_name(instance) {
instance.web.form.AddAnItemList.include({
pad_table_to: function (count) {
if (!this.view.is_action_enabled('create') || this.is_readonly()) {
this._super(count);
return;
}
this._super(count > 0 ? count - 1 : 0);
var self = this;
var columns = _(this.columns).filter(function (column) {
return column.invisible !== '1';
}).length;
if (this.options.selectable) { columns++; }
if (this.options.deletable) { columns++; }
var $cell = $('<td>', {
colspan: columns,
'class': this._add_row_class || ''
}).html(
$('<a>', {href: '#'}).text(_t("Add new row"))
.mousedown(function () {
// FIXME: needs to be an official API somehow
if (self.view.editor.is_editing()) {
self.view.__ignore_blur = true;
}
})
.click(function (e) {
e.preventDefault();
e.stopPropagation();
// FIXME: there should also be an API for that one
if (self.view.editor.form.__blur_timeout) {
clearTimeout(self.view.editor.form.__blur_timeout);
self.view.editor.form.__blur_timeout = false;
}
self.view.ensure_saved().done(function () {
self.view.do_add_record();
});
}));
var $padding = this.$current.find('tr:not([data-id]):first');
var $newrow = $('<tr>').append($cell);
if ($padding.length) {
$padding.replaceWith($newrow);
} else {
this.$current.replaceWith($newrow)
}
}
});
}
Module_Name
static
src
js
File_Name.js
views
File_Name.xml
__openerp__.py
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="account assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<!-- Include External/Custom/Own JS File. And Order Maintain. -->
<script type="text/javascript" src="/Module_Name/static/src/js/File_Name.js"></script>
</xpath>
</template>
</data>
</openerp>
odoo.define('Module_Name.File_Name', function (require) {
"use strict";
var core = require('web.core');
var ListView = require('web.ListView');
var _t = core._t;
var _lt = core._lt;
// Include "web.form_relational"
var form_relational = require('web.form_relational');
// Include X2ManyList Functionality and Modify X2ManyList Functionality
var form_relational = form_relational.X2ManyList.include({
pad_table_to: function (count) {
if (!this.view.is_action_enabled('create') || this.view.x2m.get('effective_readonly')) {
this._super(count);
return;
}
this._super(count > 0 ? count - 1 : 0);
var self = this;
var columns = _(this.columns).filter(function (column) {
return column.invisible !== '1';
}).length;
if (this.options.selectable) { columns++; }
if (this.options.deletable) { columns++; }
var $cell = $('<td>', {
colspan: columns,
'class': 'oe_form_field_x2many_list_row_add'
}).append(
$('<a>', {href: '#'}).text(_t("Add new row"))
.click(function (e) {
e.preventDefault();
e.stopPropagation();
// FIXME: there should also be an API for that one
if (self.view.editor.form.__blur_timeout) {
clearTimeout(self.view.editor.form.__blur_timeout);
self.view.editor.form.__blur_timeout = false;
}
self.view.save_edition().done(function () {
self.view.do_add_record();
});
}));
var $padding = this.$current.find('tr:not([data-id]):first');
var $newrow = $('<tr>').append($cell);
if ($padding.length) {
$padding.replaceWith($newrow);
} else {
this.$current.replaceWith($newrow);
}
},
});
});
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Module Name',
'version': '1.0',
'category': '',
'sequence': 1,
'summary': '',
'description': """ Give the Description of Module """,
'website': '',
'depends': ['web'],
'data': [
'views/File_Name.xml'
],
'demo': [],
'css': [],
'js' : [],
'installable': True,
'auto_install': False,
'application': True,
}
return {
FieldMany2ManyTags: FieldMany2ManyTags,
AbstractManyField: AbstractManyField,
X2ManyList : X2ManyList, ////Add this line in this file
};