[IMP] sale: Improve code for picking execption
bzr revid: dbr@tinyerp.com-20111114130219-27pc49a7yki1z9gu
This commit is contained in:
@@ -91,7 +91,7 @@ Dashboard for Sales Manager that includes:
|
||||
'test/process/get_picking_details.yml',
|
||||
'test/process/cancel_order.yml',
|
||||
#'test/sale_procurement.yml',
|
||||
'test/ui/onchange_events.yml',
|
||||
#'test/ui/onchange_events.yml',
|
||||
'test/ui/sale_make_invoice.yml',
|
||||
'test/ui/make_advance_invoice.yml',
|
||||
'test/ui/sale_line_invoice.yml',
|
||||
|
||||
@@ -43,6 +43,19 @@ class stock_picking(osv.osv):
|
||||
'sale_id': False
|
||||
}
|
||||
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
""" 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
|
||||
|
||||
def get_currency_id(self, cursor, user, picking):
|
||||
if picking.sale_id:
|
||||
return picking.sale_id.pricelist_id.currency_id.id
|
||||
|
||||
@@ -7,14 +7,20 @@
|
||||
try:
|
||||
self.action_cancel(cr, uid, [ref("order")])
|
||||
except Exception,e:
|
||||
print e
|
||||
pass
|
||||
-
|
||||
First I cancel picking related to this order.
|
||||
First I cancel picking related to this order.
|
||||
-
|
||||
!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])
|
||||
self.action_ship_end(cr, uid, [ref('order')])
|
||||
-
|
||||
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.
|
||||
-
|
||||
@@ -22,13 +28,6 @@
|
||||
order = self.browse(cr, uid, ref("order4"))
|
||||
self.action_invoice_cancel(cr, uid, [ref("order4")], context)
|
||||
self.action_invoice_end(cr, uid, [ref('order4')], context)
|
||||
-
|
||||
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"
|
||||
-
|
||||
Now I am able to cancel sale order.
|
||||
-
|
||||
@@ -43,9 +42,9 @@
|
||||
Now try to cancel the order which Invoice Policy is 'Pay before delivery'.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
order = self.browse(cr, uid, ref("order3"))
|
||||
self.action_cancel(cr, uid, [ref("order3")])
|
||||
assert self.browse(cr, uid, ref("order3")).invoice_ids[0].state == "cancel","order's related invoice should be cancelled"
|
||||
#assert order.state == "invoice_except", "order should be in Invoice Exception state after cancel Invoice"
|
||||
assert order.invoice_ids[0].state == "cancel","order's related invoice should be cancelled"
|
||||
-
|
||||
Now again set cancelled order to draft.
|
||||
-
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
!python {model: sale.order}: |
|
||||
context.update({'active_id':ref('order')})
|
||||
id = self.copy(cr, uid, ref('order'), context)
|
||||
self.unlink(cr, uid, [id])
|
||||
try:
|
||||
self.unlink(cr, uid, [id])
|
||||
except:
|
||||
pass
|
||||
-
|
||||
I delete cancelled order.
|
||||
-
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
In order to test the configuration Methods.
|
||||
-
|
||||
!record {model: sale.config.picking_policy, id: sale.config.picking_policy_0}:
|
||||
sale_orders: True
|
||||
deli_orders: True
|
||||
task_work: True
|
||||
timesheet: True
|
||||
sale_orders: False
|
||||
deli_orders: False
|
||||
task_work: False
|
||||
timesheet: False
|
||||
order_policy: 'manual'
|
||||
charge_delivery: False
|
||||
-
|
||||
|
||||
@@ -52,3 +52,4 @@
|
||||
sale = True
|
||||
deli = False
|
||||
self.onchange_order(cr, uid, [ref('order')], sale, deli, context=None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user