Hi,
I made it work but I would love if someone could look through it.
When I was listening for satchmo_store.shop.signals.order_cancelled it
did not get called when I manually set the status to Cancelled.
Looking through the satchmo_store.shop.signals module I find
signals.satchmo_order_status_changed.
It sends the new and the old status with the order. :)
Here is my listeners module

def my_callback(sender, oldstatus, newstatus, order, **kwargs):
    """ reset inventory when order is canceled """
    if newstatus == "Cancelled":
        orditems = order.orderitem_set.all()
        for item in orditems:
            item.product.items_in_stock += item.quantity
            item.product.save()

and I connect to it like this:

from satchmo_store.shop import signals
from listeners import my_callback

signals.satchmo_order_status_changed.connect(my_callback, sender=None)

It works great! I really need to learn more about signals.

Thank you very much for all the help.

lzantal

http://twitter.com/lzantal

On Jul 14, 9:12 am, lzantal <[email protected]> wrote:
> Hi,
> Wow thank you all for the input.
> I will get on this feature this afternoon.
>
> Thank you very much for all the help
>
> lzantal
>
> On Jul 14, 8:11 am, Chris Moffitt <[email protected]> wrote:
>
> > Good catch on the signal doc error. Would you mind submitting a ticket so we
> > don't lose track?
>
> > Thanks,
> > Chris
>
> > On Tue, Jul 14, 2009 at 10:08 AM, Bob Waycott <[email protected]> wrote:
> > > Nathan has a pretty good suggestion, but I'd point out one glaring problem
> > > I see with it.
> > > From the description (emphasis mine):
>
> > > "Send when an order is *about to be cancelled* and asks listeners if they
> > > allow to do so."
>
> > > The problem is here that the proper time to update inventory would be *
> > > after* an order is successfully cancelled, not before.
>
> > > Now, this also points out in error in the Signals documentation. We have
> > > two signals listed in the docs that say "order_sucess," but one of them 
> > > (the
> > > one after order_cancel_query) should actually be the signal
> > > 'order_cancelled.' This signal is sent whenever an order is successfully
> > > cancelled. We should update the docs to reflect the correct name soon.
>
> > > So, in short, you want to connect your listener to
> > > satchmo_store.shop.signals.order_cancelled.
>
> > > On Tue, Jul 14, 2009 at 10:47 AM, Nathan Ekstrom 
> > > <[email protected]>wrote:
>
> > >> This one would be my guess.
>
> > >>http://www.satchmoproject.com/docs/svn/signals.html#order-cancel-query
>
> > >> On Tue, Jul 14, 2009 at 8:40 AM, lzantal <[email protected]> wrote:
>
> > >>> Hi Bob,
>
> > >>> thank you for you reply. I will code up something for that so I don't
> > >>> have to do it manually.
> > >>> Could you please give me some pointers on what signals I would need to
> > >>> use?
>
> > >>> Thank you very much
>
> > >>> lzantal
>
> > >>> On Jul 14, 6:11 am, Bob Waycott <[email protected]> wrote:
> > >>> > If I recall being in that code correctly, that is a situation not
> > >>> handled
> > >>> > automatically and will require you to manually adjust store inventory.
> > >>> > You could quite easily code up a custom listener to handle it for you,
> > >>> as
> > >>> > well.
>
> > >>> > On Tue, Jul 14, 2009 at 3:55 AM, lzantal <[email protected]> wrote:
>
> > >>> > > Hi,
> > >>> > > When I set the Order Status to cancelled the inventory does not get
> > >>> > > updated.
> > >>> > > Is it something I need to do manually or am I missing something?
> > >>> > > E.g.:
> > >>> > > I have 100 piece ProductA.
> > >>> > > I buy 10.
> > >>> > > Inventory goes down to 90.
> > >>> > > I set the order status to cancelled.
> > >>> > > Inventory still shows 90.
>
> > >>> > > Thank you for all the help
>
> > >>> > > lzantal
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to