Webhook trigger on Bin change/update

We rely on submitted sales invoices updating Bin entries, then firing a webhook to do some stuff with the Actual Qty. This works fine.
However, when the Reserved Bin qty is updated with a submitted Sales Order, the webhook is not triggered.

Steps to replicate:

  • set up a webhook Bin doctype on_update or on_change (doesn’t seem to be any difference?)
  • Submit a Sales Invoice
  • Observe Bin record, Actual Qty reduced by Sales Invoice
  • webhook is triggered
  • Submit a Sales Order
  • Observe Bin record. Reserved Qty incremented by Sales Order
  • webhook does not trigger

I could trigger a webhook on Sales Order submit, then go and retrieve the Bin data, but that’s a waste of resources. I would like to understand why a change in Bin Actual Quantity triggers the webhook, but not a change in Bin Reserved Quantity.

Mike Zareno

1 Like

I am having an issue with webhook on sales order, which is never fired, even just on_change. Triggering a webhooks e.g. on an item change works fine, though. Anybody has an idea how to debug this?

Were you able to solve this issue?

No, but we moved away from sales orders and just use sales invoices
Mike

1 Like

there are following two ways to update quantity field in Bin

  1. via DB API directly, in other word record( quantity field in tabBin table) is updated via frappe.db.set_value(), event hooks in ORM is bypassed.
  2. via ORM, i.e update bin quantity field via doc object, like below
    bin = frappe.get_doc(‘Bin’, bin_name) #get the doc first
    bin.actual_qty = xxx # update the property/field
    bin.save() # save, trigger the event hook