@treeio_login_required
@handle_response_format
def ordered_product_delete(request, ordered_product_id, response_format='html'):
 ordered_product = get_object_or_404(OrderedProduct, pk=ordered_product_id)
 if ((not request.user.profile.has_permission(ordered_product, mode='w')) and (not request.user.profile.is_admin('treeio.sales'))):
  return user_denied(request, "You don't have access to this Sale Status", response_format)
 if request.POST:
  if ('delete' in request.POST):
   order_id = ordered_product.order_id
   if ('trash' in request.POST):
    ordered_product.trash = True
    ordered_product.save()
   else:
    ordered_product.delete()
   ordered_product.order.update_total()
   return HttpResponseRedirect(reverse('sales_order_view', args=[order_id]))
  elif ('cancel' in request.POST):
   return HttpResponseRedirect(reverse('sales_ordered_product_view', args=[ordered_product.id]))
 order = ordered_product.order
 return render_to_response('sales/ordered_product_delete', {'ordered_product': ordered_product, 'order': order}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def ordered_product_delete ( request , ordered_product_id , response_format = 'html' ) : ordered_product = get_object_or_404 ( OrderedProduct , pk = ordered_product_id ) if ( ( not request . user . profile . has_permission ( ordered_product , mode = 'w' ) ) and ( not request . user . profile . is_admin ( 'treeio.sales' ) ) ) : return user_denied ( request , "You don't have access to this Sale Status" , response_format ) if request . POST : if ( 'delete' in request . POST ) : order_id = ordered_product . order_id if ( 'trash' in request . POST ) : ordered_product . trash = True ordered_product . save ( ) else : ordered_product . delete ( ) ordered_product . order . update_total ( ) return HttpResponseRedirect ( reverse ( 'sales_order_view' , args = [ order_id ] ) ) elif ( 'cancel' in request . POST ) : return HttpResponseRedirect ( reverse ( 'sales_ordered_product_view' , args = [ ordered_product . id ] ) ) order = ordered_product . order return render_to_response ( 'sales/ordered_product_delete' , { 'ordered_product' : ordered_product , 'order' : order } , context_instance = RequestContext ( request ) , response_format = response_format )
orderedproduct delete .