Skip to Content
Menu
This question has been flagged
2 Replies
3768 Views

 I am developing a widget in odoo and I need that when showing a Dialog the form of the wizard  appears inside the same one

******************** WIDGET  JS CODE ***********

odoo.define('df_indicadores.grafico', function (require) {
    "use strict";


    var ControlPanelMixin = require('web.ControlPanelMixin');
    var core = require('web.core');
    var Model = require('web.Model');
    var Widget = require('web.Widget');
    var ActionManager = require('web.ActionManager');
    var Dialog = require('web.Dialog');
    var ViewManager = require('web.ViewManager');
    var _t = core._t;
    var QWeb = core.qweb;

    var Widget_Grafico = Widget.extend(ControlPanelMixin, {
        template: "test_grafico_view",


        init: function (parent, context) {
            this._super(parent, context);
        },

        start: function () {
            var self = this;

            this.$("#btn_graficar").bind("click", function () {
                self.configurar_grafica();
            });


        },
        graficar: function (data) {
            var model = new Model('df.indicadores.medida').call('calcular_indicador',[data]).then(function (result) {

                $('#container').highcharts({
                    chart: {type: 'column'},
                    title: {text: 'Indicador Plan/Real'},
                    xAxis: {categories: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']},
                    yAxis: {title: {text: 'Valor'}},
                    series: [
                        {name: 'Plan', data: result['series'][0]['data']},
                        {name: 'Real', data: result['series'][1]['data']},
                    ]

                });
            });

        },


        configurar_grafica: function () {
            var self = this;
            var action_manager = new ActionManager(this);
            var values = {};


            //var $content =  $('#tabstrip').append($('<input>', {type: 'text', class: 'o_set_qty_input'}));
            var dialog = new Dialog(this, {
                title: _t("Configurar gráfica"),
                show: {
                    effect: "fade",
                    duration: 500
                },
                hide: {
                    effect: "fade",
                    duration: 100
                },
                position: {my: "center", at: "center", of: window},
                modal: true,
                width: 470,
                buttons: [
                    {
                        text: _t("Cancelar"),
                        id: 'btn_cancel',
                        classes: "btn-primary",
                        click: function () {
                            dialog.close()
                        }
                    },
                    {
                        text: _t("Graficar"),
                        id: 'btn_config',
                        classes: "btn-primary",
                        click: function () {
                            var form = action_manager.dialog_widget.views.form.controller;
                            values = form.get_fields_values();
                            self.graficar(values);
                            dialog.close();

                        },
                    }
                ],
                //$content: $content,
            });
            //var action_manager = {
            //    type: 'ir.actions.act_window',
            //    res_model: 'configurar.grafica.wizard',
            //    views: [[false, 'form']],
            // };
            // this.do_action(action_manager);
            dialog.open();

            action_manager.appendTo(dialog.$el)
            action_manager.do_action({
                name: "Configurar gráfica",
                res_model: 'configurar.grafica.wizard',
                views: [[false, 'form']],
                type: 'ir.actions.act_window',
                flags: {

                    action_buttons: false,
                    headless: false,
                },

                target: "new"
            });

            var lolo = null;
            //dialog.$el.append(action_manager.dialog_widget.views.form.controller);
            //dialog.content = action.dialog_widget.views.form.controller
            //action_manager.appendTo(dialog.$el);


            //$content = action_manager.dialog_widget.views.form.controller;
            // dialog.$el.append(action_manager.dialog_widget.views.form.controller);
            //dialog.$el.append('<input id="create_view" string="prueba"  />');

            //var form = action_manager.dialog_widget.views.form.controller;
            ////form.on("on_button_cancel", action_manager, action_manager.dialog_stop);
            //form.on('on_button_cancel', self, function () {
            //      action_manager.dialog_stop();
            //      self.dialog.close();
            //});
            //form.on('record_saved', self, function () {
            //      action_manager.dialog_stop();
            //      self.dialog.open();
            //
            //});


        },

    });

    core.action_registry.add('widget_grafico', Widget_Grafico);

    return Widget_Grafico;

});

Avatar
Discard
Best Answer

Have you found solution ?


Avatar
Discard
Author Best Answer

I don't have solution yet, but I make that I want in other way, sorry by my english

Avatar
Discard