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">['&','&',('warehouse_id','!=', False),('qty','>',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.
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?