2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 11:35:41 +00:00

Add PO wildcard default setting (#8532)

* add PO wildcard default setting

* Revert "add PO wildcard default setting"

This reverts commit 6cc577fa73.

* use custom format spec for "wildcard with default" reference pattern

* add wildcard with default to docs

* add test for wildcard with default
This commit is contained in:
Jacob Felknor
2024-11-21 15:27:06 -07:00
committed by GitHub
parent 6250901c2f
commit 94089c94b7
4 changed files with 68 additions and 5 deletions

View File

@ -32,8 +32,9 @@ When building a reference, the following variables are available for use:
| Variable | Description |
| --- | --- |
| `{% raw %}{ref}{% endraw %}` | Incrementing portion of the reference (**required*)). Determines which part of the reference field auto-increments |
| `{% raw %}{ref}{% endraw %}` | Incrementing portion of the reference (**required*). Determines which part of the reference field auto-increments |
| `{% raw %}{date}{% endraw %}` | The current date / time. This is a [Python datetime object](https://docs.python.org/3/library/datetime.html#datetime.datetime.now) |
| `{% raw %}{?:default}{% endraw %}` | A wildcard *with default*. Any character(s) will be accepted in this position, but the reference pattern suggests the character(s) specified. |
The reference field pattern uses <a href="https://www.w3schools.com/python/ref_string_format.asp">Python string formatting</a> for value substitution.
@ -44,8 +45,9 @@ The reference field pattern uses <a href="https://www.w3schools.com/python/ref_s
Some examples below demonstrate how the variable substitution can be implemented:
| Pattern | Description | Example Output |
| Pattern | Description | Example Output(s) |
| --- | --- | --- |
| `{% raw %}PO-{ref}{% endraw %}` | Render the *reference* variable without any custom formatting | PO-123 |
| `{% raw %}PO-{ref:05d}{% endraw %}` | Render the *reference* variable as a 5-digit decimal number | PO-00123 |
| `{% raw %}PO-{ref:05d}-{?:A}{% endraw %}` | *Require* a wildcard suffix with default suggested suffix `"A"`. | PO-00123-A <br> PO-00123-B |
| `{% raw %}PO-{ref:05d}-{date:%Y-%m-%d}{% endraw %}` | Render the *date* variable in isoformat | PO-00123-2023-01-17 |