【问题标题】:How to Integrate the D3 charts in Odoo Framework?如何在 Odoo 框架中集成 D3 图表?
【发布时间】:2016-04-14 11:07:45
【问题描述】:

我是 Stack 新手,我在 odoo 中遇到了这个问题,我需要在 odoo 表单视图中为我的模型集成 d3 图表。提前致谢。

【问题讨论】:

    标签: openerp odoo-8


    【解决方案1】:

    试试这个, 我们需要在 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),因此可能有害。你应该解决这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多