[IMP] sale; purchase: correctly propagate the context arg and assume it can be given by wkf, even if wkf engine may not support it yet (it's backward compatible anyway)
bzr revid: rvalyi@gmail.com-20111219165440-sp3fp4f8xdcleu0r
This commit is contained in:
commit
1cac7a3912
|
@ -453,7 +453,7 @@ class purchase_order(osv.osv):
|
||||||
self.log(cr, uid, id, message)
|
self.log(cr, uid, id, message)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _prepare_order_picking(self, cr, uid, order, *args):
|
def _prepare_order_picking(self, cr, uid, order, context=None):
|
||||||
return {
|
return {
|
||||||
'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),
|
'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),
|
||||||
'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
|
'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
|
||||||
|
@ -466,7 +466,7 @@ class purchase_order(osv.osv):
|
||||||
'move_lines' : [],
|
'move_lines' : [],
|
||||||
}
|
}
|
||||||
|
|
||||||
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, *args):
|
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
|
||||||
return {
|
return {
|
||||||
'name': order.name + ': ' + (order_line.name or ''),
|
'name': order.name + ': ' + (order_line.name or ''),
|
||||||
'product_id': order_line.product_id.id,
|
'product_id': order_line.product_id.id,
|
||||||
|
@ -487,7 +487,7 @@ class purchase_order(osv.osv):
|
||||||
'price_unit': order_line.price_unit
|
'price_unit': order_line.price_unit
|
||||||
}
|
}
|
||||||
|
|
||||||
def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, *args):
|
def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None):
|
||||||
"""Creates pickings and appropriate stock moves for given order lines, then
|
"""Creates pickings and appropriate stock moves for given order lines, then
|
||||||
confirms the moves, makes them available, and confirms the picking.
|
confirms the moves, makes them available, and confirms the picking.
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ class purchase_order(osv.osv):
|
||||||
:return: list of IDs of pickings used/created for the given order lines (usually just one)
|
:return: list of IDs of pickings used/created for the given order lines (usually just one)
|
||||||
"""
|
"""
|
||||||
if not picking_id:
|
if not picking_id:
|
||||||
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
|
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context))
|
||||||
todo_moves = []
|
todo_moves = []
|
||||||
stock_move = self.pool.get('stock.move')
|
stock_move = self.pool.get('stock.move')
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
|
@ -515,7 +515,7 @@ class purchase_order(osv.osv):
|
||||||
if not order_line.product_id:
|
if not order_line.product_id:
|
||||||
continue
|
continue
|
||||||
if order_line.product_id.type in ('product', 'consu'):
|
if order_line.product_id.type in ('product', 'consu'):
|
||||||
move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, *args))
|
move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context))
|
||||||
if order_line.move_dest_id:
|
if order_line.move_dest_id:
|
||||||
order_line.move_dest_id.write({'location_id': order.location_id.id})
|
order_line.move_dest_id.write({'location_id': order.location_id.id})
|
||||||
todo_moves.append(move)
|
todo_moves.append(move)
|
||||||
|
@ -524,10 +524,10 @@ class purchase_order(osv.osv):
|
||||||
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
|
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
|
||||||
return [picking_id]
|
return [picking_id]
|
||||||
|
|
||||||
def action_picking_create(self,cr, uid, ids, *args):
|
def action_picking_create(self,cr, uid, ids, context=None):
|
||||||
picking_ids = []
|
picking_ids = []
|
||||||
for order in self.browse(cr, uid, ids):
|
for order in self.browse(cr, uid, ids):
|
||||||
picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, *args))
|
picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, context))
|
||||||
|
|
||||||
# Must return one unique picking ID: the one to connect in the subflow of the purchase order.
|
# Must return one unique picking ID: the one to connect in the subflow of the purchase order.
|
||||||
# In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the
|
# In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the
|
||||||
|
|
|
@ -685,7 +685,7 @@ class sale_order(osv.osv):
|
||||||
return False
|
return False
|
||||||
return canceled
|
return canceled
|
||||||
|
|
||||||
def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, *args):
|
def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None):
|
||||||
return {
|
return {
|
||||||
'name': line.name,
|
'name': line.name,
|
||||||
'origin': order.name,
|
'origin': order.name,
|
||||||
|
@ -706,7 +706,7 @@ class sale_order(osv.osv):
|
||||||
'company_id': order.company_id.id,
|
'company_id': order.company_id.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, *args):
|
def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None):
|
||||||
location_id = order.shop_id.warehouse_id.lot_stock_id.id
|
location_id = order.shop_id.warehouse_id.lot_stock_id.id
|
||||||
output_id = order.shop_id.warehouse_id.lot_output_id.id
|
output_id = order.shop_id.warehouse_id.lot_output_id.id
|
||||||
return {
|
return {
|
||||||
|
@ -733,7 +733,7 @@ class sale_order(osv.osv):
|
||||||
'price_unit': line.product_id.standard_price or 0.0
|
'price_unit': line.product_id.standard_price or 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
def _prepare_order_picking(self, cr, uid, order, *args):
|
def _prepare_order_picking(self, cr, uid, order, context=None):
|
||||||
pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
|
pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
|
||||||
return {
|
return {
|
||||||
'name': pick_name,
|
'name': pick_name,
|
||||||
|
@ -771,7 +771,7 @@ class sale_order(osv.osv):
|
||||||
self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args):
|
def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, context=None):
|
||||||
"""Create the required procurements to supply sale order lines, also connecting
|
"""Create the required procurements to supply sale order lines, also connecting
|
||||||
the procurements to appropriate stock moves in order to bring the goods to the
|
the procurements to appropriate stock moves in order to bring the goods to the
|
||||||
sale order's requested location.
|
sale order's requested location.
|
||||||
|
@ -805,13 +805,13 @@ class sale_order(osv.osv):
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
if line.product_id.product_tmpl_id.type in ('product', 'consu'):
|
if line.product_id.product_tmpl_id.type in ('product', 'consu'):
|
||||||
if not picking_id:
|
if not picking_id:
|
||||||
picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
|
picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, context))
|
||||||
move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args))
|
move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, context))
|
||||||
else:
|
else:
|
||||||
# a service has no stock move
|
# a service has no stock move
|
||||||
move_id = False
|
move_id = False
|
||||||
|
|
||||||
proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))
|
proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, context))
|
||||||
proc_ids.append(proc_id)
|
proc_ids.append(proc_id)
|
||||||
line.write({'procurement_id': proc_id})
|
line.write({'procurement_id': proc_id})
|
||||||
self.ship_recreate(cr, uid, order, line, move_id, proc_id)
|
self.ship_recreate(cr, uid, order, line, move_id, proc_id)
|
||||||
|
@ -836,9 +836,9 @@ class sale_order(osv.osv):
|
||||||
order.write(val)
|
order.write(val)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_ship_create(self, cr, uid, ids, *args):
|
def action_ship_create(self, cr, uid, ids, context=None):
|
||||||
for order in self.browse(cr, uid, ids, context={}):
|
for order in self.browse(cr, uid, ids, context=context):
|
||||||
self._create_pickings_and_procurements(cr, uid, order, order.order_line, None, *args)
|
self._create_pickings_and_procurements(cr, uid, order, order.order_line, None, context)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_ship_end(self, cr, uid, ids, context=None):
|
def action_ship_end(self, cr, uid, ids, context=None):
|
||||||
|
|
Loading…
Reference in New Issue