Hi All! I am working on a project and created this custom button. In order not to mess with the ERPNext existing code, I am calling my customized codes in my created app’s hooks.
Anyway, I have this button in Purchase Receipt that would set quantity to Purchase Receipt Items (Child). I have been looking buttons with the same functionality but can’t figure out how to code without using the “self” method since button will be called in hooks.
I tried doc = frappe.get_doc(“Purchase Receipt”, name) but will result to below error since data is not yet in the server side.
Hi @rmehta! Here’s what I’ve got. I am supposed to set received_qty to zero after pulling data from PO and let the user input whatever is receipt. Later on, I will be deleting lines with zero qty (items without receipt) with another button. So I am supposed to set received_qty using this code:
def set_qt_to_zero(name):
doc = frappe.get_doc("Purchase Receipt", name)
frappe.db.sql("""Update `tabPurchase Receipt Item` set received_qty = 0 where parent= %s""",
doc.name)
Problem is, the record is still on the client side. That is why I am getting an error.
So basically, I’d like to know more about how to manipulate data on the client side. Thanks!