def create(self, cr, user, vals, context=None):
if ('name' not in vals) or (vals.get('name')=='/'):
- seq_obj_name = self._name
+ seq_obj_name = 'stock.picking.%s' % vals.get('type', 'internal')
vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)
new_id = super(stock_picking, self).create(cr, user, vals, context)
return new_id
@return: True
"""
pickings = self.browse(cr, uid, ids, context=context)
- self.write(cr, uid, ids, {'state': 'confirmed'})
+ to_update = []
+ for pick in pickings:
+ if pick.state != 'confirmed':
+ to_update.append(pick.id)
+ if to_update:
+ self.write(cr, uid, to_update, {'state': 'confirmed'})
todo = []
for picking in pickings:
for r in picking.move_lines:
""" Cancels picking and moves.
@return: True
"""
- wf_service = netsvc.LocalService("workflow")
for pick in self.browse(cr, uid, ids):
move_ids = [x.id for x in pick.move_lines]
self.pool.get('stock.move').cancel_assign(cr, uid, move_ids)
- wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
return True
def action_assign_wkf(self, cr, uid, ids, context=None):
""" Changes picking state to assigned.
@return: True
"""
- self.write(cr, uid, ids, {'state': 'assigned'})
+ to_update = []
+ for pick in self.browse(cr, uid, ids, context=context):
+ if pick.state != 'assigned':
+ to_update.append(pick.id)
+ if to_update:
+ self.write(cr, uid, to_update, {'state': 'assigned'})
return True
def test_finished(self, cr, uid, ids):
if all([x.state != 'waiting' for x in pick.move_lines]):
return True
for move in pick.move_lines:
+ if (move.state) == 'waiting':
+ move.check_assign()
if (move.state in ('confirmed', 'draft')) and (mt == 'one'):
return False
if (mt == 'direct') and (move.state == 'assigned') and (move.product_qty):
result = {
'product_qty': 0.00
}
- warning = {}
if (not product_id) or (product_uos_qty <=0.0):
result['product_uos_qty'] = 0.0
product_obj = self.pool.get('product.product')
uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff'])
-
- # Warn if the quantity was decreased
- for move in self.read(cr, uid, ids, ['product_uos_qty']):
- if product_uos_qty < move['product_uos_qty']:
- warning.update({
- 'title': _('Warning: No Back Order'),
- 'message': _("By changing the quantity here, you accept the "
- "new quantity as complete: OpenERP will not "
- "automatically generate a Back Order.") })
- break
+
+ # No warning if the quantity was decreased to avoid double warnings:
+ # The clients should call onchange_quantity too anyway
if product_uos and product_uom and (product_uom != product_uos):
result['product_qty'] = product_uos_qty / uos_coeff['uos_coeff']
else:
result['product_qty'] = product_uos_qty
- return {'value': result, 'warning': warning}
+ return {'value': result}
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
loc_dest_id=False, partner_id=False):
# fix for bug lp:707031
# called write of related picking because changing move availability does
# not trigger workflow of picking in order to change the state of picking
+ seen = set()
wf_service = netsvc.LocalService('workflow')
for move in self.browse(cr, uid, ids, context):
- if move.picking_id:
+ if move.picking_id and move.picking_id.id not in seen:
wf_service.trg_write(uid, 'stock.picking', move.picking_id.id, cr)
+ seen.add(move.picking_id.id)
return True
#