ERPNext Conference 2019* ERPNext.com Blog

Allow edit custom field on Bin Doctype through report builder


#1

Hello i want to enable user to be able to edit a custom field i added to bin Doctype through report builder.
So far i made bin Doctype submittable and allow_on_submit for the field but it’s still not working.
Any help will be much appreciated thank you.
My system
erpnext 10.1.31
frappe 10.1.30


#2

So this was solved by creating a IsSingle Doctype which updates the value of bin_label

Here is the code

class BinSetup(Document):
	def validate(self):
		self.before_save()

	def before_save(self):
		for d in self.bin_table:

			if d.new_label:
				bin_no = frappe.db.get_value('Bin', {"item_code": d.item_code, "warehouse": d.warehouse, }, "name")
				if bin_no:
					doc = frappe.get_doc("Bin", bin_no)
					doc.bin_label = d.new_label
					doc.save()
		self.bin_table = []