Default value for category field #7259
Replies: 3 comments 5 replies
-
You cannot use |
Beta Was this translation helpful? Give feedback.
-
I suddenly realize that when editing a part, the category and name field are auto-filled. Maybe I could learn the way it presents value just like how I added initial_stock_expiry_date. In the latter part of part.js, I found this
The function accepts a pk number to fetch value, I then searched for "editpart" and found this
Apparently, when you click editpart button, you are already under certain part info page. But when creating new part, no pk can be fetched. |
Beta Was this translation helpful? Give feedback.
-
Regarding the python (backend) and javascript (frontend) mixes, refer to the comments above. But if you want to build a system that automatically sets fields for you, I would suggest creating a custom plugin rather than running a modified version of InvenTree. There are several mixing available. I would recommend taking a look at the event mixin which you could use to set certain values on a item creation. |
Beta Was this translation helpful? Give feedback.
-
Hello,
As you can see, name field can display the first item on category list with default value, but when I add
default: PartCategory.objects.first()
to category field, the form isn't even opening.How can I add a default value for category field?
Looking forward to your answer!
partial code in part.js
Beta Was this translation helpful? Give feedback.
All reactions