Exemple #1
0
    def get_child_models(self):
        """ 
            Register child model using hooks

            @hooks.register('sales_order_child_model', order=1)
            def register_child_model():
                return ChildModel
        """
        super_child_models = super().get_child_models()
        child_models = list(super_child_models).copy()

        # list function that return SalesOrderModel
        for func in hooks.get_hooks('sales_order_child_model'):
            value = func()
            if issubclass(value, SalesOrder):
                child_models.append(value)
            else:
                raise ImproperlyConfigured(
                    'Hook sales_order_child_model should return SalesOrder subclass'
                )

        return child_models
Exemple #2
0
    def get_child_models(self):
        """ 
            Register child model using hooks

            @hooks.register('product_child_model', order=1)
            def register_child_model():
                return ProductChildModel
            
        """
        super_child_models = super().get_child_models()
        child_models = list(super_child_models).copy()

        # list function that return Product subclass
        func_list = hooks.get_hooks('product_child_model')
        for func in func_list:
            value = func()
            if issubclass(value, Product):
                child_models.append(value)
            else:
                raise ImproperlyConfigured(
                    'Hook product_child_model should return Product subclass')
        return child_models
Exemple #3
0
def get_custom_admin_urls():
    custom_url_hooks = hooks.get_hooks('admin_custom_view')
    custom_urls = [path() for path in custom_url_hooks]
    return custom_urls
Exemple #4
0
 def registered_menu_items(self):
     menu_item_from_register = self._registered_menu_items
     menu_from_hooks = hooks.get_hooks(self.hook_name)
     return menu_item_from_register + menu_from_hooks