django-oscar / django-oscar-mws

Oscar module for Amazon - Marketplace Web Service
Other
12 stars 20 forks source link

'StockRecord' object has no attribute 'set_amazon_supply_quantity' #9

Closed natea closed 10 years ago

natea commented 10 years ago

When I try to 'Update product stock' in the MWS dashboard menu, the following error occurs:

Environment:

Request Method: POST
Request URL: http://localhost:8000/en-us/dashboard/profiles/

Django Version: 1.6.5
Python Version: 2.7.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.flatpages',
 'django.contrib.admin',
 'compressor',
 'south',
 'django_extensions',
 'oscar_mws',
 'oscar',
 'oscar.apps.analytics',
 'oscar.apps.checkout',
 'oscar.apps.address',
 'oscar.apps.shipping',
 'oscar.apps.catalogue',
 'oscar.apps.catalogue.reviews',
 'oscar.apps.partner',
 'oscar.apps.basket',
 'oscar.apps.payment',
 'oscar.apps.offer',
 'oscar.apps.order',
 'oscar.apps.customer',
 'oscar.apps.promotions',
 'oscar.apps.search',
 'oscar.apps.voucher',
 'oscar.apps.wishlists',
 'oscar.apps.dashboard',
 'oscar.apps.dashboard.reports',
 'oscar.apps.dashboard.users',
 'oscar.apps.dashboard.orders',
 'oscar.apps.dashboard.promotions',
 'oscar.apps.dashboard.catalogue',
 'oscar.apps.dashboard.offers',
 'oscar.apps.dashboard.partners',
 'oscar.apps.dashboard.pages',
 'oscar.apps.dashboard.ranges',
 'oscar.apps.dashboard.reviews',
 'oscar.apps.dashboard.vouchers',
 'oscar.apps.dashboard.communications',
 'haystack',
 'treebeard',
 'sorl.thumbnail']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.transaction.TransactionMiddleware',
 'oscar.apps.basket.middleware.BasketMiddleware')

Traceback:
File "/Users/nateaune/.virtualenvs/django-oscar-mws/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/nateaune/.virtualenvs/django-oscar-mws/lib/python2.7/site-packages/django/db/transaction.py" in inner
  371.                 return func(*args, **kwargs)
File "/Users/nateaune/.virtualenvs/django-oscar-mws/lib/python2.7/site-packages/django_oscar-0.7.1-py2.7.egg/oscar/views/decorators.py" in _checklogin
  32.             return view_func(request, *args, **kwargs)
File "/Users/nateaune/.virtualenvs/django-oscar-mws/lib/python2.7/site-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "/Users/nateaune/.virtualenvs/django-oscar-mws/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  87.         return handler(request, *args, **kwargs)
File "/Users/nateaune/Dropbox/code/django-oscar-mws/oscar_mws/dashboard/views.py" in post
  186.             return self.form_valid(form)
File "/Users/nateaune/Dropbox/code/django-oscar-mws/oscar_mws/dashboard/views.py" in form_valid
  171.             getattr(self, 'handle_{0}'.format(selected))(marketplace, form)
File "/Users/nateaune/Dropbox/code/django-oscar-mws/oscar_mws/dashboard/views.py" in handle_update_stock
  78.             update_inventory(products)
File "/Users/nateaune/Dropbox/code/django-oscar-mws/oscar_mws/fulfillment/gateway.py" in update_inventory
  353.                 stockrecord.set_amazon_supply_quantity(quantity, commit=False)

Exception Type: AttributeError at /en-us/dashboard/profiles/
Exception Value: 'StockRecord' object has no attribute 'set_amazon_supply_quantity'
roadsideseb commented 10 years ago

I'll take a look at that tomorrow, it's either a bug or something that should be in the docs. I'll try and correct it either way.

natea commented 10 years ago

Any luck?

roadsideseb commented 10 years ago

Not yet, I'll be on my way to work shortly and take a look at that.

roadsideseb commented 10 years ago

I've taken a look at this and this is actually just another indicator of lack in documentation. For the handling/tracking of stock in MWS, the StockRecord from Oscar has to be extended to hand over responsibility of stock tracking to MWS. I've added a section to the docs that describes how to use the AmazonStockTrackingMixin that provides a default implementation of that. If your set up is more complex than that with different types of fulfillment partners, you might have to customise them to your specific needs.