【问题标题】:Create a read write field inside Odoo widget在 Odoo 小部件中创建一个读写字段
【发布时间】:2017-10-04 11:31:33
【问题描述】:
我关注了https://www.odoo.com/documentation/9.0/howtos/web.html的文档
但是当我尝试创建一个读写字段时,我收到了错误Cannot read property 'get' of undefined
<t t-if="! widget.get('effective_readonly')">
<input type="text"></input>
</t>
此代码无法识别widget。我应该在模板中使用什么identifier?如果没有内置identifier,在哪里定义identifier?怎么做?
【问题讨论】:
标签:
python
openerp
odoo-8
qweb
【解决方案1】:
在init 函数中
local.FieldNewWidget = instance.web.form.AbstractField.extend({
init: function(parent, options) {
this._super(parent, options);
this._super.apply(this, arguments);
this.set("value", "");
this.widget = this;
},
...
这里
display_field: function() {
var self = this;
self.$el.empty();
self.$el.append(QWeb.render('yourNewTemplate', {widget: self, data: data}));
...
完成