You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FR] Allow week number to be used in auto batch generation #5933
Please verify that this feature request has NOT been suggested before.
I checked and didn't find a similar feature request
Problem statement
I want to auto generate batch codes with the year and week number. (Common in manufacturing). For example, today would be 2023-46.
I would like to develop this and think I know how. I just need to be pointed in the right direction.
Suggested solution
In the backend where the {{year}} is replaced with the actual year, add a "week" or "weeknumber" option that will replace with the week number.
# Shamelessly stolen from chat gptfromdatetimeimportdatetimecurrent_date=datetime.now()
current_week_number=current_date.isocalendar()[1]
current_week_number#46
Describe alternatives you've considered
This could also be done by writing a custom validation mixin I think? But that seems like a lot of work for a one off, especially when others might benefit from this too.
Activity
matmair commentedon Nov 19, 2023
We are just passing in values to a context so this should be a 1-2 LoC change. I think we would be happy to merge the suggested function.
InvenTree/InvenTree/stock/models.py
Lines 301 to 308 in a084108
SchrodingersGat commentedon Dec 15, 2023
@lfg-seth would you be able to submit a PR to implement this?