shuup.simple_supplier package

Subpackages

Submodules

shuup.simple_supplier.forms module

class shuup.simple_supplier.forms.StockAdjustmentForm(sales_unit: SalesUnit | None = None, *args, **kwargs)[source]

Bases: Form

__init__(sales_unit: SalesUnit | None = None, *args, **kwargs)[source]
clean_delta()[source]
base_fields = {'delta': <shuup.core.fields.FormattedDecimalFormField object>, 'purchase_price': <django.forms.fields.DecimalField object>}
declared_fields = {'delta': <shuup.core.fields.FormattedDecimalFormField object>, 'purchase_price': <django.forms.fields.DecimalField object>}
property media

Return all media required to render the widgets on this form.

class shuup.simple_supplier.forms.AlertLimitForm(sales_unit: SalesUnit | None = None, *args, **kwargs)[source]

Bases: Form

__init__(sales_unit: SalesUnit | None = None, *args, **kwargs)[source]
clean_alert_limit()[source]
base_fields = {'alert_limit': <django.forms.fields.DecimalField object>}
declared_fields = {'alert_limit': <django.forms.fields.DecimalField object>}
property media

Return all media required to render the widgets on this form.

class shuup.simple_supplier.forms.StockManagedForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: Form

base_fields = {'stock_managed': <django.forms.fields.BooleanField object>}
declared_fields = {'stock_managed': <django.forms.fields.BooleanField object>}
property media

Return all media required to render the widgets on this form.

shuup.simple_supplier.models module

class shuup.simple_supplier.models.StockAdjustment(id, product, supplier, created_on, created_by, delta, purchase_price_value, type)[source]

Bases: Model

product

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

supplier

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

created_on

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

delta

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

purchase_price_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

purchase_price

Property for Price object.

Similar to MoneyProperty, but also has includes_tax field.

Operaters with TaxfulPrice and TaxlessPrice objects.

type
currency
includes_tax
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

created_by_id
get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)
get_type_display(*, field=<enumfields.fields.EnumIntegerField: type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
product_id
supplier_id
class shuup.simple_supplier.models.StockCount(id, alert_limit, stock_managed, product, supplier, logical_count, physical_count, stock_value_value)[source]

Bases: Model

alert_limit

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

stock_managed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

product

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

supplier

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

logical_count

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

physical_count

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

stock_value_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

stock_value

Property for Price object.

Similar to MoneyProperty, but also has includes_tax field.

Operaters with TaxfulPrice and TaxlessPrice objects.

stock_unit_price

Property for Price object.

Similar to MoneyProperty, but also has includes_tax field.

Operaters with TaxfulPrice and TaxlessPrice objects.

currency
includes_tax
property stock_unit_price_value
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
product_id
supplier_id

shuup.simple_supplier.module module

class shuup.simple_supplier.module.SimpleSupplierModule(supplier: Supplier, options: Dict)[source]

Bases: BaseSupplierModule

identifier: str = 'simple_supplier'
name: str = 'Simple Supplier'
get_orderability_errors(shop_product, quantity, customer, *args, **kwargs)[source]
Parameters:
Return type:

iterable[ValidationError]

get_stock_statuses(product_ids, *args, **kwargs)[source]
Parameters:

product_ids – Iterable of product IDs.

Returns:

Dict of {product_id: ProductStockStatus}.

adjust_stock(product_id, delta, purchase_price=0, created_by=None, type=StockAdjustmentType.INVENTORY, *args, **kwargs)[source]

Adjusts the stock for the given product_id.

update_stock(product_id, *args, **kwargs)[source]

Supplier module update stock should always bump product cache and send shuup.core.signals.stocks_updated signal.

ship_products(shipment, product_quantities, *args, **kwargs)[source]

shuup.simple_supplier.notify_events module

class shuup.simple_supplier.notify_events.AlertLimitReached(**variable_values)[source]

Bases: Event

cache_key_fmt = 'stock_alert_%s_%s'
identifier = 'alert_limit_reached'
name = 'Alert Limit Reached'
__init__(**variable_values)[source]
run(shop)[source]
bindings = {}
variables = {'dispatched_last_24hs': <shuup.notify.base.Variable object>, 'product': <shuup.notify.base.Variable object>, 'shop_email': <shuup.notify.base.Variable object>, 'supplier': <shuup.notify.base.Variable object>, 'supplier_email': <shuup.notify.base.Variable object>}

shuup.simple_supplier.notify_script_template module

class shuup.simple_supplier.notify_script_template.StockLimitEmailForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: Form

base_fields = {'last24hrs': <django.forms.fields.BooleanField object>, 'recipient': <django.forms.fields.EmailField object>}
declared_fields = {'last24hrs': <django.forms.fields.BooleanField object>, 'recipient': <django.forms.fields.EmailField object>}
property media

Return all media required to render the widgets on this form.

class shuup.simple_supplier.notify_script_template.StockLimitEmailScriptTemplate(script_instance=None)[source]

Bases: GenericSendEmailScriptTemplate

Parameters:

script_instance (shuup.notify.models.script.Script|None) – script instance to change or None

identifier = 'stocks_limit_email'
event

alias of AlertLimitReached

name = 'Send Stock Limit Alert Email'
description = 'Send me an email when a product stock is lower than the configured limit.'
help_text = "This script will send an email to the configured destination alerting about the a product's low stock of a supplier. You can configure to not send the same email multiple times in a period of 24 hours. Every time a product's stock reach its configured limit, this notification will be fired and the email sent."
extra_js_template_name = None
base_form_class

alias of StockLimitEmailForm

get_script_steps(form)[source]

Returns a list of Steps to use in the script.

Parameters:

form (django.forms.Form|None) – validated form to use or None

Returns:

list of steps

Return type:

list[shuup.notify.Step]

get_initial()[source]

Returns the initial data to use for configuration form.

Note: You must also check for the bound script_instance attribute. One can edit the Script created by the template editor through the form this instance provides. This way, when a script instance is bound, you must return the the representantion of the Script as the initial form data.

Returns:

initial data to to use in configuration form

Return type:

dict

can_edit_script()[source]
We can only edit the script when:
  • the event is AlertLimitReached

  • has a single SendMail action in steps (oterwise we don’t know which to edit)

shuup.simple_supplier.product_copy_signal_handler module

shuup.simple_supplier.product_copy_signal_handler.handle_product_copy(sender, shop, copied, copy, supplier=None, **kwargs)[source]

shuup.simple_supplier.utils module

shuup.simple_supplier.utils.get_current_stock_value(supplier_id, product_id)[source]

Count stock values for supplier and product combination

Logical count is events minus orders bought (not cancelled) describing how many products is currently orderable Physical count is events minus orders actually sent describing how many products is currently in stock

Parameters:
  • supplier_id – supplier_id to count stock values for

  • product_id – product_id to count stock values for

Returns:

logical and physical count for product

Return type:

dict

shuup.simple_supplier.utils.get_stock_information_div_id(supplier, product)[source]
shuup.simple_supplier.utils.get_stock_information_html(supplier, product)[source]

Get html string to show current stock information for product

Parameters:
Returns:

html div as a string

Return type:

str

shuup.simple_supplier.utils.get_stock_adjustment_div(request, supplier, product)[source]

Get html string to adjust stock values

Contains inputs for purchase_price_value and delta

Parameters:
Returns:

html div as a string

Return type:

str

Module contents

class shuup.simple_supplier.ShuupSimpleSupplierAppConfig(*args, **kwargs)[source]

Bases: AppConfig

name = 'shuup.simple_supplier'
verbose_name = 'Shuup Simple Supplier'
label = 'simple_supplier'
default_auto_field = 'django.db.models.BigAutoField'
provides = {'admin_module': ['shuup.simple_supplier.admin_module:StocksAdminModule'], 'admin_product_form_part': ['shuup.simple_supplier.admin_module.forms:SimpleSupplierFormPart'], 'notify_event': ['shuup.simple_supplier.notify_events:AlertLimitReached'], 'notify_script_template': ['shuup.simple_supplier.notify_script_template:StockLimitEmailScriptTemplate'], 'supplier_module': ['shuup.simple_supplier.module:SimpleSupplierModule']}

See /provides for details about the provides variable.

ready()[source]

Override this method in subclasses to run code when Django starts.