In the linked topic I was investigating possibility to change Bin DocType bin.py file.
Alternative would be to use hooks in custom app to update Bin Item -s related to Bin document.
I found list of events which can be hooked here https://frappe.io/docs/user/en/guides/basics/hooks but I did not find the explanation when these events are triggered. Can somebody point me to this information?
I would like to hook to https://github.com/frappe/erpnext/blob/develop/erpnext/stock/doctype/bin/bin.py function set_projected_qty(self) to trigger Bin Item generation code located in my custom app.
When I look bin.py I can see that set_projected_qty(self) is triggered by
- validate(self) - which can be hooked from custom app
- update_stock(self, args, allow_negative_stock=False, via_landed_cost_voucher=False):
‘’‘Called from erpnext.stock.utils.update_bin’’’ - this seems to be called from outside
‘’‘Update qty reserved for production from Production Item tables
in open production orders’’’ - this seems to be called from outside
- update_reserved_qty_for_sub_contracting(self): - this seems to be called from outside
What I want to do is to detect when some document or event changes Bin projected quatity. If I can detect this I can update my Bin Item -s related to this Bin.
If change events are triggered from multiple places from outside how can I know if validate(self) is called always when Bin is changed? Or some other hooks event like on_update etc. is always triggered on Bin change with self.db_set() or self.db_update().
Or there is better way to hook or override function set_projected_qty(self)?