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

Hello,

I'm in odoo 8.

I have a wizard to choose a category and display a board.board (I want many graphs in this board, but for the moment, only one is displayed).

It works well. But If I click a two times in a row on the wizard menuitem, it doesn't work. The first time, my board.board displays well. But the second time, my board is empty. No error...

I have to refresh the page if I want it to work two times in a row. Or I have to click on another menuitem before to come back to my wizard...

Since I was trying to imitate the existing wizard_valuation_history class of Odoo, I tries to click many times in a row of its menuitem and this wizard always displays correctly its tree view page... Why not mine?

Could you help?


Python code of my wizard :

class wizard_choose_category(models.TransientModel):
    _name = 'wizard.choose.category'
    _description = 'Wizard that allow to choose a category'

    choose_category = fields.Many2one('product.category', string='Product category', domain=[('parent_id','!=', 1)])
        #date = fields.Datetime('Date', default=fields.Datetime.now, required=True)
   
    @api.multi
    def open_table(self):
        self.ensure_one()
        ctx = dict(
            self._context,
            category=self.choose_category.id
            )
            
 
        res = {
            'domain': "[]",
            'name': _('My dashboard by category'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'board.board',
            'type': 'ir.actions.act_window',
            'context': ctx,
            'view_id': self.env.ref('vtm2_cavavin_inventory_graphs.inventory_by_category_form').id,
            'target': 'current',
        }
 
        return res


XML of the board :

<record id="inventory_by_category_form" model="ir.ui.view">
            <field name="name">Inventory dashboard form</field>
            <field name="model">board.board</field>
            <field name="arch" type="xml">
                <form string="Inventory dashboard" >
                    <board style="1" >
                        <column>
                          <action context="{'choosen_category':9}" string="Inventory of your choosen category - pivot table"
                                 name="%(action_inventory_pivot_1)d"  />
                        </column>
                    </board>
                </form>
            </field>
        </record>


XML of my graph action :

<record id="action_inventory_pivot_1" model="ir.actions.act_window">
            <field name="name">My inventory pivot #1</field>
            <field name="res_model">stock.quant</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
 
            <field name="domain">['&amp;','&amp;',('warehouse_id','!=', False),('qty','&gt;',0),
                    ('product_category_id','=',context.get('choosen_category'))]</field>
            <field name="view_id" ref="inventory_pivot_1" />
 </record>




EDIT #1

If I display my board directly from a new menuitem, without a wizard, I can click as many times as I want on the menuitem. The board always displays my graph correctly...

<record id="inventory_category_boards" model="ir.actions.act_window">
            <field name="name">Inventory - by category</field>
            <field name="res_model">board.board</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="usage">menu</field>
            <field name="view_id" ref="inventory_by_category_form" />
        </record>


EDIT #2

In my wizard, If I use :

'target': 'new',

Instead of :

'target': 'current',

My board and graph is correctly displayed even if I click many times on the wizard menuitem. But it is displayed in a modal window (popup)... It is not what I want.


Avatar
Discard
Author

May be I should create an init() method to my wizard. When the wizard opens, it initializes the current view. So, when the user confirms the wizard, it displays the board in a initialized current window... Is it doable?

Best Answer

Hi Pascal,

Here again, you find a very weird case in v8, I don't know if this are fixed in v9 or latter but here is a quick solution for your problem.

Just load this JS code in any of your modules and you will be ok

openerp.your_module_name_here = function (instance) {
    instance.web.ActionManager.include({     dialog_stop: function (reason) {     if(this.inner_widget != null && this.inner_action != null && reason &&      this.inner_action.res_model == 'board.board' && this.inner_widget.active_view == 'form' &&     reason.res_model == "board.board" && reason.target == "current"){     this.inner_widget.views.form.controller.destroy();     }     this._super.apply(this, arguments);     }     });
}
Avatar
Discard
Author

I could never have found it myself! Never. Ouf! Once again, I have to say to you : 1000 thanks!

LIke magic!

Author

When I see what you can do in Odoo, I understand that I have still many many many work to do to become a master!

I have a lot of imagination and patience to read and find the code!! :)

Related Posts Replies Views Activity
2
Mar 15
6616
2
Mar 15
2944
0
Mar 15
5945
3
Oct 24
56192
0
Mar 15
6702