[IMP]sale: Improve code for active the workflow of shipping_exception
bzr revid: dbr@tinyerp.com-20111115092034-u2ng806gttg8zw3l
This commit is contained in:
parent
a640e1f836
commit
a2207b22fc
|
@ -757,6 +757,7 @@ class sale_order(osv.osv):
|
|||
:return: True
|
||||
"""
|
||||
proc_ids = []
|
||||
move_obj = self.pool.get('stock.move')
|
||||
for line in order_lines:
|
||||
if line.state == 'done':
|
||||
continue
|
||||
|
@ -768,7 +769,7 @@ class sale_order(osv.osv):
|
|||
if line.product_id.product_tmpl_id.type in ('product', 'consu'):
|
||||
if not picking_id:
|
||||
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
|
||||
move_id = self.pool.get('stock.move').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, *args))
|
||||
else:
|
||||
# a service has no stock move
|
||||
move_id = False
|
||||
|
@ -783,11 +784,11 @@ class sale_order(osv.osv):
|
|||
for pick in order.picking_ids:
|
||||
for move in pick.move_lines:
|
||||
if move.state == 'cancel':
|
||||
mov_ids = self.pool.get('stock.move').search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)])
|
||||
mov_ids = move_obj.search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)])
|
||||
if mov_ids:
|
||||
for mov in move_obj.browse(cr, uid, mov_ids):
|
||||
# FIXME: the following seems broken: what if move_id doesn't exist? What if there are several mov_ids? Shouldn't that be a sum?
|
||||
self.pool.get('stock.move').write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
||||
move_obj.write(cr, uid, [move_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})
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
|
|
@ -221,7 +221,8 @@
|
|||
<record id="trans_ship_ship_except" model="workflow.transition">
|
||||
<field name="act_from" ref="act_ship"/>
|
||||
<field name="act_to" ref="act_ship_except"/>
|
||||
<field name="condition">test_state('canceled')</field>
|
||||
<field name="signal">ship_exception</field>
|
||||
|
||||
</record>
|
||||
<record id="trans_ship_except_ship" model="workflow.transition">
|
||||
<field name="act_from" ref="act_ship_except"/>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import netsvc
|
||||
|
||||
class stock_move(osv.osv):
|
||||
_inherit = 'stock.move'
|
||||
|
@ -47,14 +48,10 @@ class stock_picking(osv.osv):
|
|||
""" Changes picking state to cancel.
|
||||
@return: True
|
||||
"""
|
||||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
ids2 = [move.id for move in pick.move_lines]
|
||||
self.pool.get('stock.move').action_cancel(cr, uid, ids2, context)
|
||||
self.write(cr, uid, ids, {'state': 'cancel', 'invoice_state': 'none'})
|
||||
self.log_picking(cr, uid, ids, context=context)
|
||||
sale_id = self.browse(cr, uid, ids)[0].sale_id.id
|
||||
self.pool.get('sale.order').write(cr, uid, sale_id, {'state':'shipping_except'})
|
||||
return True
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'sale.order', sale_id, 'ship_exception', cr)
|
||||
return super(stock_picking, self).action_cancel(cr, uid, ids)
|
||||
|
||||
def get_currency_id(self, cursor, user, picking):
|
||||
if picking.sale_id:
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
!python {model: sale.order}: |
|
||||
order = self.browse(cr, uid, ref("order"))
|
||||
self.pool.get('stock.picking').action_cancel(cr, uid, [picking.id for picking in order.picking_ids])
|
||||
assert order.picking_ids[0].state == "cancel","order's related picking should be cancelled"
|
||||
-
|
||||
I check order status in "Shipping Exception" and related picking is in cancel state.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
order = self.browse(cr, uid, ref("order"))
|
||||
assert order.picking_ids[0].state == "cancel","order's related picking should be cancelled"
|
||||
assert order.state == "shipping_except", "order should be in Ship Exception state after cancel shipment"
|
||||
-
|
||||
I try to cancel the invoice.
|
||||
|
|
Loading…
Reference in New Issue