8000 Order Statuses are lacking · Issue #1211 · shuup/shuup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Order Statuses are lacking #1211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Pikkupomo opened this issue Mar 14, 2018 · 0 comments
Open

Order Statuses are lacking #1211

Pikkupomo opened this issue Mar 14, 2018 · 0 comments

Comments

@Pikkupomo
Copy link
Contributor

When your order is paid and you want to go back "one step" to previous OrderStatus it means that you have to prune through the OrderLogEntry objects to find last status_change and then match the name to OrderStatus to find the correct one.

Simple example of this:

def get_last_order_status_change(order):
    return order.log_entries.filter(
        identifier="status_change"
    ).values_list(
        "message", "created_on"
    ).order_by("-created_on").first()


def resolve_previous_order_status_change(order, default_status=None):
    last_status = get_last_order_status_change(order)
    if not last_status:
        if not default_status:
            default_status = OrderStatus.objects.get_default_initial()
        return default_status, default_status
    frm, to = last_status[0].split(":")[1].split("to")
    from_status = OrderStatus.objects.filter(translations__name=frm.strip()).first()
    to_status = OrderStatus.objects.filter(translations__name=to.strip()).first()
    return from_status, to_status

It would make sense if Shuup had an OrderStatusHistory which would help matching the status changes better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0