Skip to content

[FR] Allow week number to be used in auto batch generation #5933

Closed

Description

@lfg-seth

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 gpt
from datetime import datetime
current_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.

Examples of other systems

No response

Do you want to develop this?

  • I want to develop this.

Activity

  1. added
    enhancement
    triage:not-checked
    on Nov 17, 2023
  2. added
    plugin
    and removed
    triage:not-checked
    on Nov 19, 2023
  3. matmair commented on Nov 19, 2023

    @matmair
    Member

    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.

    context = {
    'date': now,
    'year': now.year,
    'month': now.month,
    'day': now.day,
    'hour': now.minute,
    'minute': now.minute,
    }

  4. added this to the 0.14.0 milestone on Dec 15, 2023
  5. SchrodingersGat commented on Dec 15, 2023

    @SchrodingersGat
    Member

    @lfg-seth would you be able to submit a PR to implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementplugin

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions