【发布时间】:2016-04-14 11:07:45
【问题描述】:
我是 Stack 新手,我在 odoo 中遇到了这个问题,我需要在 odoo 表单视图中为我的模型集成 d3 图表。提前致谢。
【问题讨论】:
我是 Stack 新手,我在 odoo 中遇到了这个问题,我需要在 odoo 表单视图中为我的模型集成 d3 图表。提前致谢。
【问题讨论】:
试试这个, 我们需要在 view.xml 文件中的表单视图字段中配置小部件。
view.xml
<form string="Graph">
<field name="name" widget="test"/>
</form>
需要创建一个js文件然后我们需要像这样扩展class-openerp.web.form.FieldChar.extend,
D3_chart.js
openerp.transform_organization_chart = function(openerp) {
openerp.web.form.widgets.add('test','openerp.web.form.test');
openerp.web.form.test = openerp.web.form.FieldChar.extend(
{
template: 'test-button',
init: function () {
this._super.apply(this, arguments);
this._start = null;
},
start: function() {
console.log('START');
this.Myfunction();
},
Myfunction: function()
{
}
});
}
为我们的图表创建template.xml文件,这里我们需要编写html模板。模板id和扩展字段字符名称应该相同。
template.xml
<template id="test-button">
<script type="text/javascript" src="/transform_organization_chart/static/src/js/d3.js"></script>
<div t-name="test-button">
<div id="orgChartContainer">
<div id="orgChart"></div>
</div>
<div id="consoleOutput"></div>
</div>
</template>
【讨论】:
_gaq),因此可能有害。你应该解决这个问题。