awesto / django-shop

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

No class implements abstract base model: `BaseOrder`. #792

Open bwrm opened 4 years ago

bwrm commented 4 years ago

Problem I'm trying to create own SelfCollectionWorkflowMixin. I've created class:

class SelfCollectionWorkflowMixin(object):
    TRANSITION_TARGETS = {
        'ready_for_take': _("Ready for take"),
        'order_completed': _("Order completed"),
    }
    def __init__(self, *args, **kwargs):
        if not isinstance(self, BaseOrder):
            raise ImproperlyConfigured("class 'SelfCollectionWorkflowMixin' is not of type 'BaseOrder'")
        super(SelfCollectionWorkflowMixin, self).__init__(*args, **kwargs)

    @transition(field='status', source='created', target='ready_for_take',
                custom=dict(admin=True, button_name=_("Ready for take")))
    def ready_for_take(self):
        return 'ready_for_take'`

settings.py:
`SHOP_ORDER_WORKFLOWS = [
      ...
    'myshop.modifiers.workflows.SelfCollectionWorkflowMixin',
]

While running it is showing the following error:

raise ImproperlyConfigured(msg.format(self.__name__))
django.core.exceptions.ImproperlyConfigured: No class implements abstract base model: `BaseOrder`.

But BaseOrder implemented as Order in MyShop as described in https://django-shop.readthedocs.io/en/latest/reference/order.html

jrief commented 4 years ago

It seems as if you never materialize the Order model. The easiest way to do this is to import the default Order model somewhere in your project.

...
from shop.models.defaults.order import Order
bwrm commented 4 years ago

Yes, Order model doesn't materialized, but Order and OrderItem imported to myshop.models.__init__.py.

from shop.models.defaults.order import Order
from shop.models.defaults.order_item import OrderItem
from myshop.models.address import ShippingAddress
...

This problem occur, when creating any custom workflow.

jrief commented 4 years ago

I'm sorry, without fully seeing your code, I can't reproduce that error.

dinoperovic commented 4 years ago

Hi @bwrm, @jrief.

I've had this happen to me recently, it was due to the location of modifers/providers/workflows. If for a custom payment you put all the code in payment.py this will happen. I believe modifiers must be specified in a separate file from workflows to avoid checks for materialized order. Hope this helps. =)

jrief commented 4 years ago

@bwrm could you please paste the full stack using a service such as https://dpaste.de