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
IPN uniqueness evaluation including revision #4618
Please verify that this feature request has NOT been suggested before.
I checked and didn't find a similar feature request
Problem statement
Would it be possible to include the Revision in the IPN uniqueness evaluation in the same way as for part description?
In all tables I then see revision duplicated in both the IPN and Revision column, If I understand correctly the "last used serial number" would then also be evaluated for the base number and not restart for each revision.
Sorry it there is already a setting controlling this that I have not found.
Suggested solution
Include the Revision in the IPN uniqueness evaluation
Describe alternatives you've considered
Currently I need to include the revision in the IPN also.
Hi there @gunstr
It would probably be possible with some small adaptations in core code, but not with plugins currently.
You are correct that it would probably need an adaption for the serial counter. I think that could be a challenge as we allow any chars in the revision field and we would probably need a migration for that.
Thoughts @SchrodingersGat
@SchrodingersGat Sorry it was a typo from my side that made this confusing. It should be "name" - not "description"... Let me try to explain:
For each new part the name has to be unique. If you add a revision multiple parts with the same name can be created. Correct?
Also (and here I'm not sure I have the complete picture) those revisions will be treated as completely separate parts with their own BoM, pricing etc. Only one exception I have found is that the serial counter will use the same number pool for all revisions - perfect!
I use IPN's and as i need them to be unique I set PART_ALLOW_DUPLICATE_IPN to false which is fine for most parts.
Some parts also have different revisions and thus I currenty have to assign a new IPN for each revision.
So my question is if it would be possible to allow one IPN for multiple revisions also when PART_ALLOW_DUPLICATE_IPN is set to false in the same way as one name can have multiple revisions?
I was thinking a bit more on this but I have to admit I'm a bit on deep water here. If I set PART_ALLOW_DUPLICATE_IPN to true instead can I then create a plug-in that validates that the IPN+Revision is unique? You mentioned it's probably not possible. Is that because the validation mixin cannot be used to validate the uniqueness vs other parts so that would be a dead end? I looked at the validation plugin samples, and it seems to only act on the actual part and cannot reference other parts in the database.
@gunstr@matmair I would disagree here, I think that you certainly can have a custom validation routine for the IPN which operates exactly as you require.
The "part" instance is passed to this function, so you have access to any attribute of the part. Writing a custom plugin here would be the correct approach IMO
Now the plugin is uploaded, you find it here. I have only installed the plugin locally as I have never done any PIP packaging. This could be a good case for me to learn but I thought it's better not to wait until I have done that.
@walkermc20 appreciate if you can test and and let me know if it works for you also.
@SchrodingersGat However, I tried to move it out from the src/InvenTree/plugins directory in my installation by pointing the plugins_plugin_dir variable in the config file to a custom directory where I put the plugin. But when I do so it will not be found by the system. I can't really figure out what I'm doing wrong - are you aware of any common mistakes that might cause this? It's not really a problem for me to keep it inside the src tree but as you do not recommend to do so in the documentation I thought it would be better to get it working...
As a little side note I found that the documentation refers to plugins_plugin_dir as the variable name while in the config_template.yaml is plugin_dir.
@gunstr cool plugin!
If you want a hint about Python packaging you can take a look at this repo or the meta-package I use for packaging and creating new plugins.
My installation is Bare Metal (on a VM), unfortunately I can't be of so much help on Docker. The only issue I had was that I could not move the plugin outsisde the InvenTree source code as I mentioned above.
@SchrodingersGat I guess this issue can be considered as resolved now and can be closed? If you want to add a link to the plugin to the samples page please feel free to do so.
Activity
matmair commentedon Apr 17, 2023
Hi there @gunstr
It would probably be possible with some small adaptations in core code, but not with plugins currently.
You are correct that it would probably need an adaption for the serial counter. I think that could be a challenge as we allow any chars in the revision field and we would probably need a migration for that.
Thoughts @SchrodingersGat
SchrodingersGat commentedon Apr 19, 2023
@gunstr I'm not fully sure that I'm following what you are asking for here
Currently the "PART_ALLOW_DUPLICATE_IPN" setting just allows duplicate IPNs across part, the "description" of the part is not checked as part of this?
gunstr commentedon Apr 20, 2023
@SchrodingersGat Sorry it was a typo from my side that made this confusing. It should be "name" - not "description"... Let me try to explain:
For each new part the name has to be unique. If you add a revision multiple parts with the same name can be created. Correct?
Also (and here I'm not sure I have the complete picture) those revisions will be treated as completely separate parts with their own BoM, pricing etc. Only one exception I have found is that the serial counter will use the same number pool for all revisions - perfect!
I use IPN's and as i need them to be unique I set PART_ALLOW_DUPLICATE_IPN to false which is fine for most parts.
Some parts also have different revisions and thus I currenty have to assign a new IPN for each revision.
So my question is if it would be possible to allow one IPN for multiple revisions also when PART_ALLOW_DUPLICATE_IPN is set to false in the same way as one name can have multiple revisions?
More clear now?
gunstr commentedon Apr 24, 2023
@matmair I found the section in the code that validates the IPN and it confirms that with PART_ALLOW_DUPLICATE_IPN set to false the same IPN cannot be used for different revisions.
I was thinking a bit more on this but I have to admit I'm a bit on deep water here. If I set PART_ALLOW_DUPLICATE_IPN to true instead can I then create a plug-in that validates that the IPN+Revision is unique? You mentioned it's probably not possible. Is that because the validation mixin cannot be used to validate the uniqueness vs other parts so that would be a dead end? I looked at the validation plugin samples, and it seems to only act on the actual part and cannot reference other parts in the database.
matmair commentedon Apr 24, 2023
@gunstr we do not expose the revision of the current part to the validation function so you can not validate it.
gunstr commentedon Apr 24, 2023
@matmair Thanks, then I understand why a plugin is not an option.
SchrodingersGat commentedon Apr 26, 2023
@gunstr @matmair I would disagree here, I think that you certainly can have a custom validation routine for the IPN which operates exactly as you require.
From the code (linked above):
InvenTree/InvenTree/part/models.py
Line 574 in 070e2af
And from the plugin code:
InvenTree/InvenTree/plugin/base/integration/mixins.py
Line 65 in 36d17c0
The "part" instance is passed to this function, so you have access to any attribute of the part. Writing a custom plugin here would be the correct approach IMO
gunstr commentedon Apr 26, 2023
Thanks a lot @SchrodingersGat. I will give it a try to write a plugin in the coming days and let you know.
10 remaining items
SchrodingersGat commentedon Jun 3, 2023
@gunstr looking forward to seeing what you've come up with :)
gunstr commentedon Jun 4, 2023
Now the plugin is uploaded, you find it here. I have only installed the plugin locally as I have never done any PIP packaging. This could be a good case for me to learn but I thought it's better not to wait until I have done that.
@walkermc20 appreciate if you can test and and let me know if it works for you also.
@SchrodingersGat However, I tried to move it out from the
src/InvenTree/pluginsdirectory in my installation by pointing theplugins_plugin_dirvariable in the config file to a custom directory where I put the plugin. But when I do so it will not be found by the system. I can't really figure out what I'm doing wrong - are you aware of any common mistakes that might cause this? It's not really a problem for me to keep it inside the src tree but as you do not recommend to do so in the documentation I thought it would be better to get it working...As a little side note I found that the documentation refers to
plugins_plugin_diras the variable name while in the config_template.yaml isplugin_dir.matmair commentedon Jun 4, 2023
@gunstr cool plugin!
If you want a hint about Python packaging you can take a look at this repo or the meta-package I use for packaging and creating new plugins.
SchrodingersGat commentedon Jun 5, 2023
@andrewwetzel23 could be a few things:
config.yamlgunstr commentedon Jun 6, 2023
My installation is Bare Metal (on a VM), unfortunately I can't be of so much help on Docker. The only issue I had was that I could not move the plugin outsisde the InvenTree source code as I mentioned above.
SchrodingersGat commentedon Jun 7, 2023
https://docs.inventree.org/en/latest/extend/plugins/install/#enable-plugin-support
matmair commentedon Jun 7, 2023
@andrewwetzel23 that was actually already developed but is not released at the moment.
wolflu05 commentedon Jun 7, 2023
Ref: #4964
gunstr commentedon Jun 15, 2023
@SchrodingersGat I guess this issue can be considered as resolved now and can be closed? If you want to add a link to the plugin to the samples page please feel free to do so.
matmair commentedon Jun 15, 2023
@gunstr we can add it to the plugin repo if you want.