# pylint: disable=W0614,W0401
from oscar.core.loading import get_class, is_model_registered

AbstractStockRecord = get_class("partner.abstract_models", "AbstractStockRecord")

###############################################################################
# This is how to override an oscar app, while keeping the overriding app      #
# overridable itself.                                                         #
# The mechanism is the same as in oscar, the only think different is the way  #
# ``__all__`` is being updated with the exports of the original oscar app.    #
###############################################################################

__all__ = []

if not is_model_registered("partner", "StockRecord"):

    class StockRecord(AbstractStockRecord):
        pass

    __all__.append("StockRecord")

# both these lines are reruired, the first one imports all objects the are not
# implemented above into the current namespace.
# the second line updates the __all__ variable of the current namespace with
# the objects from the oscar namespace.
# THIS ENSURE THAT THE SAME CAN BE DONE BY ANOTHER APP, SO THIS APP CAN BE ONCE
# MORE EXTENDED BY ANOTHER APP.

from oscar.apps.partner.models import *
from oscar.apps.partner.models import __all__ as some

__all__.extend(some)
