更新旧API中的上下文

时间:2018-09-18 16:55:31

标签: odoo odoo-8 odoo-9

这是原始方法,但是我想用super调用它,并在其上下文中添加广告,但是它是旧的API,在这里我有点困惑。

应调用firstStep stepType2 lastStep move_scrap方法之后,但什么也没有发生,并且不调用write

并且with_context当然不起作用

write

我确实尝试过类似的事情

class stock_move_scrap(osv.osv_memory):
    _name = "stock.move.scrap"
    _description = "Scrap Products"


  def move_scrap(self, cr, uid, ids, context=None):
    """ To move scrapped products
    @param self: The object pointer.
    @param cr: A database cursor
    @param uid: ID of the user currently logged in
    @param ids: the ID or list of IDs if we want more than one
    @param context: A standard dictionary
    @return:
    """
    if context is None:
        context = {}
    move_obj = self.pool.get('stock.move')
    move_ids = context['active_ids']
    for data in self.browse(cr, uid, ids):
        move_obj.action_scrap(cr, uid, move_ids,
                         data.product_qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id,
                         context=context)
    if context.get('active_id'):
        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
        if move.picking_id:
            return {
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'stock.picking',
                'type': 'ir.actions.act_window',
                'res_id': move.picking_id.id,
                'context': context
            }
    return {'type': 'ir.actions.act_window_close'}

1 个答案:

答案 0 :(得分:1)

您的问题是,您要用[]替换期望的ID arg,从而从超级调用中删除ID。 将您的最后一行从以下位置更改:

super(stock_move_scrap,self).move_scrap(cr, uid, [], context=ctx)

收件人:

super(stock_move_scrap,self).move_scrap(cr, uid, ids, context=ctx)