Managing multiple dealers at django oscar

I am the new django-oscar and I need to manage several sellers so that they can add their product and see, for example. they can have their own toolbar, I follow this URL

https://django-oscar.readthedocs.org/en/releases-0.6/howto/multi_dealer_setup.html

and override the Oscar partner model, for example: -

from django.db import models from oscar.apps.partner.abstract_models import AbstractPartner from oscar.core.compat import AUTH_USER_MODEL from django.utils.translation import ugettext_lazy as _ class Partner(AbstractPartner): user = models.OneToOneField( AUTH_USER_MODEL, related_name="partner", blank=True, verbose_name=_("Users")) from oscar.apps.partner.models import * 

Now the link above has a line that I don't get

"You need to force the creation of a StockRecord with each product. When a product is created, Stockrecord.partner is set to self.request.user.partner (if necessary) and therefore a connection is created."

If anyone has an idea about my problem, then please let me know how I can achieve it.

Thanks in advance: -)

+5
source share
1 answer

This means that whenever you create a new Product object, you also need to create a new StockRecord object for it. The StockRecord object contains information such as product price, currency, and the partner / seller that provides it. Since you decide to have several partners, you will need to connect the new products that you create to the partner who provides them.

Something like that:

 from oscar.core.loading import get_model Product = get_model('catalogue', 'Product') ProductClass = get_model('catalogue', 'ProductClass') Partner = get_model('partner', 'Partner') StockRecord = get_model('partner', 'StockRecord') shoes = ProductClass.objects.get(name='Shoes') nike_air = Product.objects.create(title='Nike Air', product_class=shoes) nike = Partner.objects.get(name='Nike') stock_record = StockRecord.objects.create( partner=nike, partner_sku='nike-air-123' product=nike_air, price_currency='EUR', price_excl_tax='200' ) 
0
source

Source: https://habr.com/ru/post/1245136/


All Articles