Hi all, i want to make custom in item, if i check the automatically create batch i want to batch_number_series auto filled with “.abbr.YY.MM.####.”. is anyone can help me with this? thanks a lot
Just use the default options in ERPNext: check the ‘Automatically Create New Batch’ checkbox and add the Batch Number series.
This will work so that if you don’t provide any batch value while creating entries, a new batch will be created based on where the last series left off.
If you want to create your own batch value, then create a new batch ID or use an old batch ID before submitting the entry,
just choose the value yourself. It will then use that batch ID.
no, i need when i check the checkbox, the batch_number_series value will be auto filled with “.abbr.YY.MM.####.” so that i don’t need to always manually fill the batch_number_series value
Sorry for the confusion. For this, please add a custom checkbox field and write a custom script on the before_insert
hook
Ex:
Add a Server Scriptand and custom checkbox field like this
The result will look like this:
- Checkbox Checked: The script runs and sets the custom value to field batch number series
- Checkbox Unchecked: The script does not run
can u give me the script?
if doc.custom_create_batch_series_automatically:
doc.batch_number_series = 'abbr.YY.DD.####'
oo, i almost forgot about this. thanks a lot