Skip to content

IPN uniqueness evaluation including revision #4618

Closed

Description

@gunstr

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.

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 Apr 17, 2023
  2. removed
    triage:not-checked
    on Apr 17, 2023
  3. matmair commented on Apr 17, 2023

    @matmair
    Member

    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

  4. added
    part
    on Apr 17, 2023
  5. SchrodingersGat commented on Apr 19, 2023

    @SchrodingersGat
    Member

    @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?

  6. gunstr commented on Apr 20, 2023

    @gunstr
    ContributorAuthor

    @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?

  7. gunstr commented on Apr 24, 2023

    @gunstr
    ContributorAuthor

    @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.

  8. matmair commented on Apr 24, 2023

    @matmair
    Member

    @gunstr we do not expose the revision of the current part to the validation function so you can not validate it.

  9. gunstr commented on Apr 24, 2023

    @gunstr
    ContributorAuthor

    @matmair Thanks, then I understand why a plugin is not an option.

  10. SchrodingersGat commented on Apr 26, 2023

    @SchrodingersGat
    Member

    @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):

    result = plugin.validate_part_ipn(self.IPN, self)

    And from the plugin code:

    def validate_part_ipn(self, ipn: str, part: part.models.Part):

    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

  11. added
    question
    plugin
    and removed
    enhancement
    on Apr 26, 2023
  12. gunstr commented on Apr 26, 2023

    @gunstr
    ContributorAuthor

    Thanks a lot @SchrodingersGat. I will give it a try to write a plugin in the coming days and let you know.

  13. 10 remaining items

  14. SchrodingersGat commented on Jun 3, 2023

    @SchrodingersGat
    Member

    @gunstr looking forward to seeing what you've come up with :)

  15. gunstr commented on Jun 4, 2023

    @gunstr
    ContributorAuthor

    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.

  16. matmair commented on Jun 4, 2023

    @matmair
    Member

    @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.

  17. SchrodingersGat commented on Jun 5, 2023

    @SchrodingersGat
    Member

    @andrewwetzel23 could be a few things:

    • Have you restarted the server?
    • Anything set in your environment variables will override the values in config.yaml
  18. gunstr commented on Jun 6, 2023

    @gunstr
    ContributorAuthor

    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.

  19. matmair commented on Jun 7, 2023

    @matmair
    Member

    @andrewwetzel23 that was actually already developed but is not released at the moment.

  20. wolflu05 commented on Jun 7, 2023

    @wolflu05
    Member

    Ref: #4964

  21. gunstr commented on Jun 15, 2023

    @gunstr
    ContributorAuthor

    @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.

  22. matmair commented on Jun 15, 2023

    @matmair
    Member

    @gunstr we can add it to the plugin repo if you want.

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

    partpluginquestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions