Loaning Stock Items / Information for Creating an AppMixin #5203
Replies: 5 comments 19 replies
-
I think you do not need the app Mixin, maybe metadata is sufficient. You can set any json as metadata on a stock location with a plugin. |
Beta Was this translation helpful? Give feedback.
-
AppMixins are a very advanced feature with no guardrails. The plugin has full access to everything (databases, filesystem, security) and can mess up/destroy every part of the application. The lack of documentation is deliberate - at least from my side. For a start, you can look at this plugin and study djangos tutorial. I do not recommend using AppMixins if you are not comfortable with Django. |
Beta Was this translation helpful? Give feedback.
-
In summary, AppMixins are an extreme measure, and one too extreme for this use case. It is suggested that you use a normal plugin and edit the metadata following this tutorial here. I will hopefully start work on a plugin to managing loaning items, and share it on the inventree plugins page, so stay tuned (or create it yourself) if you need the same functionality. Anyways, thanks so much for the help guys, really truly appreciate it! |
Beta Was this translation helpful? Give feedback.
-
Hello again, Since my last messages, I have gone back to believing that an AppMixin would be the best. This is because we would like to be able to see a history of lent items, have a separate set of users able to loan (ones that should not have to login to Inventree, so not able to use the default 'Users'). See what items a user is currently borrowing. Also, we would like to be able to send email notifications to users when the due date is getting closer (and passed). If I were to do the original solution, and add Metadata to the StockItems, many operations would require iterating over every single Stock Item (Items a user is loaning and email notifications for example), which is not as good of a solution as creating new tables would be. I have also spent some time looking through examples, learning a bit of django (obviously not an expert, but everything's making sense so far). Going through the django tutorials. The one thing I can't seem to wrap my head around is how do I tell Inventree/django that I have a model prepared for my plugin? Additionally, how do I run migrations on my plugin? Some of the things I've tried:
I have tried almost every combination of my files being in a package/not in a package, file layout, imports, django manage.py commands, etc. I can't figure out how to add the model to my plugin... I believe the thing that has tricked me up the most is the whole AppMixin installing a plugin as an app automatically for you. I don't know how to also have it automagically add my model, or tell it to add my model, etc. I understand you guys are extremely busy, so I am very appreciative of any time you are able to spend with my questions. I really appreciate y'all! |
Beta Was this translation helpful? Give feedback.
-
Let's assume 1: Issue - The other aspects of the plugin do not work (ex: nav bar) 2: Issue - Inventree seems unable to read the file? Still no navbar and things, but also, the settings page can't read the author or version (of any plugin) and produces an error at the general stage with the name frozen importlib._bootstrap, and error: Should I have the init.py file (should it be a package) or not? Should it be it's own "top level directory" like example 1, or a plugin like example 2? I keep saying it, but I do keep meaning it. I appreciate you guys spending time answering common/noob questions so I may be caught up to speed. Your effort is really appreciated! |
Beta Was this translation helpful? Give feedback.
-
Hello there,
Overview of our needs/original issue:
We need to mark stock items as loaned, loanable, who it was loaned to, the due date of returning the item, a front end to loan out items, amongst other things.
What I tried:
I have tried looking up my issue, and I cannot find any plugins that do this.
I have also tried changing the location to "Loaned", which sort of works, but it is more complicated to figure out where it originally was, who has it, etc. You can use the notes but using it in this way is more of a bodge than an intentional feature.
Other half of the issue
I am willing to work on a plugin for this feature. However, I need help starting. I believe the type of plugin I need to create is an AppMixin based upon the fact that I would need to add to the "central database" (have no clue how the database is setup in inventree/how to access it). How would I go about creating an AppMixin? The documentation is very limited on this. Admittedly, I do not have much experience with djangos app system, however even looking through their docs, I can't figure out how I would edit the stock item's database table, or even how to start developing an AppMixin. Despite this lack of django experience, I do have a good amount of python/js/database/general cs knowledge that once I figure out how to start, I should be able to continue from there.
What I am asking for
Could I have documentation, assistance, or a crash course in starting creation of an AppMixin? I can't figure out how to start, so I am asking here!
Additional Info:
I have been known to not fully explain my issues. I have tried my best here, but there is probably something obvious missing. If you need more info from me, clarification, anything, just ask; I'm not perfect.
Beta Was this translation helpful? Give feedback.
All reactions