jrief / django-shop

A Django based shop system
http://www.django-shop.org
BSD 3-Clause "New" or "Revised" License
32 stars 13 forks source link

add 'product_code' to admin.py to all variants #27

Closed vivazzi closed 8 years ago

vivazzi commented 8 years ago

Add 'product_code' to admin.py to all variants (simle, polymorphic, i18n), because there is bug with add two SmartCard trough admin panel on site, because SmartCard has product_code as unique. Then add one SmartCard is ok. Then add else one SmartCard is error.

We need 'product_code' in fieldsets, for example for simple variant:

@admin.register(SmartCard)
class SmartCardAdmin(SortableAdminMixin, CMSPageAsCategoryMixin, admin.ModelAdmin):
    fieldsets = (
        (None, {
            'fields': ('name', 'slug', 'unit_price', 'active', 'description', 'product_code'),
        }),
        (_("Properties"), {
            'fields': ('manufacturer', 'storage', 'card_type', 'speed',)
        }),
    )
    inlines = (ProductImageInline,)
    prepopulated_fields = {'slug': ('name',)}
    list_display = ('name', 'unit_price', 'active',)