Skip to content

Instantly share code, notes, and snippets.

View nabinhait's full-sized avatar

Nabin Hait nabinhait

View GitHub Profile
@nabinhait
nabinhait / next_alphanumeric_number.py
Last active February 18, 2020 13:41
set item code based on incremental alphanumeric number
def custom_validate(self):
# serial_no is a custom field in item group which can be any alphanumeric number
serial_no = webnotes.conn.get_value("Item Group", self.doc.item_group, "serial_no")
#increment serial_no value and assign to item_code
next_serial_no = self.next_string(serial_no)
self.doc.item_code = next_serial_no
# update incremented serial_no in item group
webnotes.conn.set_value("Item Group", self.doc.item_group, "serial_no", next_serial_no)