How to Add "Return Product" Functionality after Product is "Delivered".

32 views
Skip to first unread message

Clifton Avil D'Souza

unread,
Jun 20, 2019, 4:09:57 AM6/20/19
to django-oscar
I want to add "Return Product" after "Product Delivery" functionality in Django Oscar. in settings.pyi added below code
OSCAR_ORDER_STATUS_PIPELINE = {
'Pending': ('Processing', 'Cancelled',),
'Processing': ('Shipped', 'Cancelled',),
'Shipped': ('Delivered', 'Return', 'Returned', 'Cancelled',),
'Returned': ('Return', 'Returned',),
'Delivered': (),
'Cancelled': (),
}

OSCAR_ORDER_STATUS_CASCADE
= {
 
'Processing': 'In progress',
 
'Shipped': 'Shipped',
 
'Delivered': 'Delivered',
 
'Returned': 'Returned',
 
'Cancelled': 'Cancelled'
}

i have written Ajax function to change the status after Order gets "Delivered" to "Return". below is the function.

@csrf_exempt
def return_order(request):
# Return Order after Delivery
 
if request.is_ajax():
    data
= request.body.decode('utf-8')
   
try:
        order
= Order.objects.get(id=int(data))
       
EventHandler().handle_order_status_change(order=order, new_status='Return')
       
return HttpResponse(json.dumps({'status': 'True', 'msg': 'OK'}))
   
except Exception as e:
       
print(e)
       
return HttpResponse(json.dumps({'status': 'False', 'msg': 'Error'}))

I am geting Error something like this

'Return' is not a valid status for order 100213 (current status: 'Delivered')


Sid

unread,
Jun 20, 2019, 4:41:12 AM6/20/19
to django-oscar
Modify as below. It should do the job

'Delivered': ('Return',),
Message has been deleted

Clifton Avil D'Souza

unread,
Jun 20, 2019, 5:20:31 AM6/20/19
to django-oscar
Thnak you. it worked. i also want to add "Returned Product" but in Admin Dashboard there are no options its showing " This order can't have its status changed.".


On Thursday, June 20, 2019 at 1:39:57 PM UTC+5:30, Clifton Avil D'Souza wrote:

Clifton Avil D'Souza

unread,
Jun 20, 2019, 5:29:18 AM6/20/19
to django-oscar
I fixed it thanks

--
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/a4186dd0-8ff1-4a66-9822-9cd5c4a15d35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Regards,
Clifton
Reply all
Reply to author
Forward
0 new messages