shuup.admin.modules.orders package

Subpackages

Submodules

shuup.admin.modules.orders.json_order_creator module

class shuup.admin.modules.orders.json_order_creator.AdminOrderSource(shop)[source]

Bases: OrderSource

get_validation_errors()[source]
is_cash_order()[source]
class shuup.admin.modules.orders.json_order_creator.AdminOrderCreator(request=None)[source]

Bases: OrderCreator

Initialize order creator.

Parameters:

request (django.http.HttpRequest|None) – Optional request object for backward compatibility. Passing non-None value is DEPRECATED.

class shuup.admin.modules.orders.json_order_creator.AdminOrderModifier[source]

Bases: OrderModifier

class shuup.admin.modules.orders.json_order_creator.JsonOrderCreator[source]

Bases: object

__init__()[source]
static safe_get_first(model, **lookup)[source]
static is_empty_address(address_data)[source]

An address will have at least a tax_number field. It will still be considered empty.

add_error(error)[source]
property is_valid
property errors
create_source_from_state(state, creator=None, ip_address=None, save=False, order_to_update=None)[source]

Create an order source from a state dict unserialized from JSON.

Parameters:
Returns:

The created order source, or None if something failed along the way.

Return type:

OrderSource|None

create_order_from_state(state, creator=None, ip_address=None)[source]

Create an order from a state dict unserialized from JSON.

Parameters:
Returns:

The created order, or None if something failed along the way.

Return type:

Order|None

update_order_from_state(state, order_to_update, modified_by=None)[source]

Update an order from a state dict unserialized from JSON.

Parameters:
Returns:

The created order, or None if something failed along the way.

Return type:

Order|None

get_removed_product_ids(state, order_to_update)[source]

Collect product ids for products which were removed from the order.

Parameters:
Returns:

set

update_stock_for_removed_products(removed_ids, shop)[source]

Update stocks for products which were completely removed from the updated order.

Parameters:
  • removed_ids (set) – Set of removed product ids.

  • shop (shuup.core.models.Shop) – Shop instance where this order is made.

shuup.admin.modules.orders.mass_actions module

class shuup.admin.modules.orders.mass_actions.CancelOrderAction[source]

Bases: PicotableMassAction

label = 'Cancel'
identifier = 'mass_action_order_cancel'
process(request, ids)[source]

Process the given ids in masses.

Parameters:
  • requestWSGIRequest

  • ids – list of ids.

Returns:

None

class shuup.admin.modules.orders.mass_actions.OrderConfirmationPdfAction[source]

Bases: PicotableFileMassAction

label = 'Print Confirmation PDF(s)'
identifier = 'mass_action_order_confirmation_pdf'
process(request, ids)[source]

Process and return HttpResponse.

Example

response = HttpResponse(content_type=”text/csv”) response[‘Content-Disposition’] = ‘attachment; filename=”mass_action.csv”’ writer = csv.writer(response) writer.writerow([‘First row’, ‘Foo’, ‘Bar’, ‘Baz’]) return response

Parameters:
  • requestWSGIRequest

  • ids – list of ids.

Returns:

HttpResponse

class shuup.admin.modules.orders.mass_actions.OrderDeliveryPdfAction[source]

Bases: PicotableFileMassAction

label = 'Print Delivery PDF(s)'
identifier = 'mass_action_order_delivery_pdf'
process(request, ids)[source]

Process and return HttpResponse.

Example

response = HttpResponse(content_type=”text/csv”) response[‘Content-Disposition’] = ‘attachment; filename=”mass_action.csv”’ writer = csv.writer(response) writer.writerow([‘First row’, ‘Foo’, ‘Bar’, ‘Baz’]) return response

Parameters:
  • requestWSGIRequest

  • ids – list of ids.

Returns:

HttpResponse

shuup.admin.modules.orders.receivers module

shuup.admin.modules.orders.receivers.handle_custom_payment_return_requests(sender, order, *args, **kwargs)[source]

shuup.admin.modules.orders.sections module

class shuup.admin.modules.orders.sections.BasicDetailsOrderSection[source]

Bases: Section

identifier: str = 'order_details'
name: str | Any = 'Details'
icon: str = 'fa-info-circle'
template: str = 'shuup/admin/orders/_detail_section.jinja'
order: int = 0
classmethod visible_for_object(order, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(order, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

class shuup.admin.modules.orders.sections.PaymentOrderSection[source]

Bases: Section

identifier: str = 'payments'
name: str | Any = 'Payments'
icon: str = 'fa-dollar'
template: str = 'shuup/admin/orders/_detail_payments.jinja'
extra_js: str = 'shuup/admin/orders/_detail_payments_js.jinja'
order: int = 1
classmethod visible_for_object(order, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(order, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

class shuup.admin.modules.orders.sections.ShipmentSection[source]

Bases: Section

identifier: str = 'shipments_data'
name: str | Any = 'Shipments'
icon: str = 'fa-truck'
template: str = 'shuup/admin/orders/_order_shipments.jinja'
order: int = 2
static visible_for_object(order, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

static get_context_data(order, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

class shuup.admin.modules.orders.sections.LogEntriesOrderSection[source]

Bases: Section

identifier: str = 'log_entries'
name: str | Any = 'Log Entries'
icon: str = 'fa-pencil'
template: str = 'shuup/admin/orders/_order_log_entries.jinja'
extra_js: str = 'shuup/admin/orders/_order_log_entries_extra_js.jinja'
order: int = 3
classmethod visible_for_object(order, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(order, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

class shuup.admin.modules.orders.sections.AdminCommentSection[source]

Bases: Section

identifier: str = 'admin_comment'
name: str | Any = 'Admin comment/notes'
icon: str = 'fa-comment-o'
template: str = 'shuup/admin/orders/_admin_comment.jinja'
extra_js: str = 'shuup/admin/orders/_admin_comment_extra_js.jinja'
order: int = 4
classmethod visible_for_object(order, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(order, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

class shuup.admin.modules.orders.sections.OrderHistorySection[source]

Bases: Section

identifier: str = 'order_status_history'
name: str | Any = 'Status history'
icon: str = 'fa-history'
template: str = 'shuup/admin/orders/_order_status_history.jinja'
order: int = 5
classmethod visible_for_object(order, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(order, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

shuup.admin.modules.orders.toolbar module

class shuup.admin.modules.orders.toolbar.OrderDetailToolbar(order)[source]

Bases: Toolbar

__init__(order)[source]
build()[source]
class shuup.admin.modules.orders.toolbar.CreatePaymentAction(object, **kwargs)[source]

Bases: DropdownItem

Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(object, **kwargs)[source]
Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

class shuup.admin.modules.orders.toolbar.SetPaidAction(object, **kwargs)[source]

Bases: PostActionDropdownItem

Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(object, **kwargs)[source]
Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

class shuup.admin.modules.orders.toolbar.CreateRefundAction(object, **kwargs)[source]

Bases: DropdownItem

Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(object, **kwargs)[source]
Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

class shuup.admin.modules.orders.toolbar.EditAddresses(object, **kwargs)[source]

Bases: DropdownItem

Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(object, **kwargs)[source]
Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

shuup.admin.modules.orders.utils module

Order utilities and helper classes.

class shuup.admin.modules.orders.utils.OrderInformation(order)[source]

Bases: object

Helper class for order information display.

__init__(order)[source]
add_info(info_dict)[source]

Add information to the order display.

get_info()[source]

Get all order information.

provides_info()[source]

Check if this instance provides information.

property order

Order ordering for sorting.

property information

Information content.

Module contents

class shuup.admin.modules.orders.OrderEntry(text, url, icon=None, category=None, ordering=99999, aliases=(), **kwargs)[source]

Bases: MenuEntry

name = 'Orders'
get_badge(request)[source]

Should return a dictionary with the information of the badge or None: ```

{

“tag”: “info|success|danger|warning”, “value”: “my value”

}

```

class shuup.admin.modules.orders.OrderModule[source]

Bases: AdminModule

name = 'Orders'
breadcrumbs_menu_entry = <shuup.admin.modules.orders.OrderEntry object>
get_urls()[source]
Return type:

list[django.urls.RegexURLPattern]

get_menu_entries(request)[source]
Return type:

list[shuup.admin.base.MenuEntry]

get_search_results(request, query)[source]
Return type:

list[shuup.admin.base.SearchResult]

get_notifications(request)[source]
Return type:

list[shuup.admin.base.Notification]

get_model_url(object, kind, shop=None)[source]

Retrieve an admin URL for the given object of the kind kind.

A falsy value must be returned if the module does not know how to reverse the given object.

Parameters:
Returns:

The reversed URL or none.

Return type:

str|None

get_help_blocks(request, kind)[source]
Parameters:
  • request (django.http.request.HttpRequest) – Request.

  • kind (str) – block kind. Currently “setup” or “quicklink”.

Return type:

list[shuup.admin.views.home.HelpBlock]

class shuup.admin.modules.orders.OrderStatusModule[source]

Bases: AdminModule

name = 'Order Status'
breadcrumbs_menu_entry = <shuup.admin.modules.orders.OrderEntry object>
get_urls()[source]
Return type:

list[django.urls.RegexURLPattern]

get_menu_entries(request)[source]
Return type:

list[shuup.admin.base.MenuEntry]

get_model_url(object, kind, shop=None)[source]

Retrieve an admin URL for the given object of the kind kind.

A falsy value must be returned if the module does not know how to reverse the given object.

Parameters:
Returns:

The reversed URL or none.

Return type:

str|None