fix button to open related move

This commit is contained in:
Yannick Vaucher
2014-09-08 18:38:14 +02:00
committed by Víctor Martínez
parent d1393ffee1
commit 00afdf6c88
2 changed files with 13 additions and 12 deletions

View File

@@ -45,8 +45,7 @@ class ProductTemplate(models.Model):
ref = 'stock_reserve.action_stock_reservation_tree'
product_ids = self._get_products()
action_dict = self._get_act_window_dict(ref)
action_dict['domain'] = ("[('product_id','in',[" +
','.join(map(str, product_ids)) + "])]")
action_dict['domain'] = [('product_id', 'in', product_ids)]
action_dict['context'] = {
'search_default_draft': 1,
'search_default_reserved': 1
@@ -77,7 +76,7 @@ class ProductProduct(models.Model):
ref = 'stock_reserve.action_stock_reservation_tree'
product_id = self._ids[0]
action_dict = self.product_tmpl_id._get_act_window_dict(ref)
action_dict['domain'] = "[('product_id','=', %s)]" % product_id
action_dict['domain'] = [('product_id', '=', product_id)]
action_dict['context'] = {
'search_default_draft': 1,
'search_default_reserved': 1

View File

@@ -181,16 +181,18 @@ class StockReservation(models.Model):
@api.multi
def open_move(self):
assert len(self._ids) == 1, "1 ID expected, got %r" % self._ids
reserv = self[0].move_id
data_obj = self.env['ir.model.data']
assert len(self.ids) == 1, "1 ID expected, got %r" % self.ids
reserv = self.move_id
IrModelData = self.env['ir.model.data']
ref_form2 = 'stock.action_move_form2'
action = data_obj.xmlid_to_object(ref_form2)
action_dict = action.read()
action = IrModelData.xmlid_to_object(ref_form2)
action_dict = action.read()[0]
action_dict['name'] = _('Reservation Move')
# open directly in the form view
ref_form = 'stock.view_move_form'
view_id = data_obj.xmlid_to_res_id(ref_form)
action['views'] = [(view_id, 'form')]
action['res_id'] = reserv['move_id']
return action
view_id = IrModelData.xmlid_to_res_id(ref_form)
action_dict.update(
views=[(view_id, 'form')],
res_id=reserv.id,
)
return action_dict