[IMP] stock: Improve the Return picking wizard take the move line which is done state
bzr revid: sbh@tinyerp.com-20100922095243-nslm43jyhvldbpo7
This commit is contained in:
parent
d672ae367f
commit
6e479c58ad
|
@ -1972,13 +1972,15 @@ class stock_move(osv.osv):
|
|||
@return:
|
||||
"""
|
||||
track_flag = False
|
||||
partial_datas=''
|
||||
picking_ids = []
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
price_type_obj = self.pool.get('product.price.type')
|
||||
product_obj = self.pool.get('product.product')
|
||||
partial_obj=self.pool.get('stock.partial.picking')
|
||||
partial_id=partial_obj.search(cr,uid,[])
|
||||
partial_datas=partial_obj.read(cr,uid,partial_id)[0]
|
||||
if partial_id:
|
||||
partial_datas=partial_obj.read(cr,uid,partial_id)[0]
|
||||
if context is None:
|
||||
context = {}
|
||||
for move in self.browse(cr, uid, ids):
|
||||
|
@ -1997,7 +1999,7 @@ class stock_move(osv.osv):
|
|||
self.action_done(cr, uid, [move.move_dest_id.id], context=context)
|
||||
|
||||
self._create_product_valuation_moves(cr, uid, move, context=context)
|
||||
prodlot_id = partial_datas.get('move%s_prodlot_id'%(move.id), False)
|
||||
prodlot_id =partial_datas and partial_datas.get('move%s_prodlot_id'%(move.id), False)
|
||||
if prodlot_id:
|
||||
self.write(cr, uid, [move.id], {'prodlot_id': prodlot_id})
|
||||
self.write(cr, uid, ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
|
||||
|
|
|
@ -70,10 +70,11 @@ class stock_return_picking(osv.osv_memory):
|
|||
pick_obj = self.pool.get('stock.picking')
|
||||
pick = pick_obj.browse(cr, uid, record_id)
|
||||
for m in [line for line in pick.move_lines]:
|
||||
if 'return%s'%(m.id) not in self._columns:
|
||||
self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True)
|
||||
if 'invoice_state' not in self._columns:
|
||||
self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be Invoiced'), ('none', 'None')], string='Invoice State', required=True)
|
||||
if m.state=='done':
|
||||
if 'return%s'%(m.id) not in self._columns:
|
||||
self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True)
|
||||
if 'invoice_state' not in self._columns:
|
||||
self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be Invoiced'), ('none', 'None')], string='Invoice State', required=True)
|
||||
for rec in m.move_history_ids2:
|
||||
if rec.product_qty==m.product_qty:
|
||||
raise osv.except_osv(_('Warning !'), _("There is no product to return!"))
|
||||
|
@ -97,9 +98,8 @@ class stock_return_picking(osv.osv_memory):
|
|||
if record_id:
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
pick = pick_obj.browse(cr, uid, record_id)
|
||||
if pick.state != 'done':
|
||||
if pick.state not in['done','confirmed']:
|
||||
raise osv.except_osv(_('Warning !'), _("The Picking is not completed yet!\nYou cannot return picking which is not in 'Done' state!"))
|
||||
|
||||
return_history = {}
|
||||
for m_line in pick.move_lines:
|
||||
return_history[m_line.id] = 0
|
||||
|
@ -109,13 +109,10 @@ class stock_return_picking(osv.osv_memory):
|
|||
arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Provide the quantities of the returned products.')]
|
||||
for m in [line for line in pick.move_lines]:
|
||||
quantity = m.product_qty
|
||||
if quantity > return_history[m.id] and (quantity - return_history[m.id])>0:
|
||||
if m.state=='done' and quantity > return_history[m.id] and (quantity - return_history[m.id])>0:
|
||||
arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
|
||||
res['fields']['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True}
|
||||
res.setdefault('returns', []).append(m.id)
|
||||
# if not res.get('returns',False): Todo : It may be used
|
||||
# raise osv.except_osv(_('Warning!'),_('There is no product to return!'))
|
||||
|
||||
arch_lst.append('<field name="invoice_state"/>\n<newline/>')
|
||||
res['fields']['invoice_state']={'string':_('Invoice state'), 'type':'selection','required':True, 'selection':[('2binvoiced', _('To Be Invoiced')), ('none', _('None'))]}
|
||||
arch_lst.append('<group col="2" colspan="4">')
|
||||
|
|
Loading…
Reference in New Issue