Skip to content

Revision Improvements - #7585

Merged
SchrodingersGat merged 48 commits into
inventree:masterfrom
SchrodingersGat:revision-of
Jul 12, 2024
Merged

SchrodingersGat merged 48 commits into
inventree:masterfrom
SchrodingersGat:revision-of

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented Jul 8, 2024 •

Copy link
Copy Markdown
Member

This PR enhances support for part "revisions" - now in addition to the existing "revision" field, the "Part" model now has the "revision_of" field, which points to another part. This allows a particular part to be "deprecated" but kept in the database.

User interface elements have been added (in the PUI in particular) to easily switch between part revisions, and make them obvious when available

TODO

  • Update / improve revision documentation
  • Add playwright tests

Screenshots

The "revision selector" dropdown appears for parts where there are multiple revisions available:

image

image

Clicking on a particular revision takes you to that revision.


looking for feedback at this stage, before progressing much further.

@matmair @wolflu05 @bberg115

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature part Related to Part models labels Jul 8, 2024
@SchrodingersGat SchrodingersGat added this to the 0.16.0 milestone Jul 8, 2024
@netlify

netlify Bot commented Jul 8, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 113b5a2
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/6690a1770512110008241a71
😎 Deploy Preview https://deploy-preview-7585--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 86 (no change from production)
Best Practices: 92 (no change from production)
SEO: 70 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

dependabot Bot and others added 25 commits July 8, 2024 13:36

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general.
Regarding the backend I would prefer if we would work with a bit more flexible model to enable adoption to different:

  • a mixin for the Part model (and future ones like Orders, Stock, ...) that adds a revision_of and a revision FK field
  • a generic Revision model that has metadata enabled and is used to keep information about the creation of a revision (user, date, note, delta)

As for creating new revisions: it would be great if we could implement the StateTransitionMixin and handle_transition to add the possibility for plugins to influence the creation of new revisions. I could provide that as a separate PR too.

Comment on lines +674 to +679
if self.revision_of.revision_of:
raise ValidationError({
'revision_of': _(
'Cannot make a revision of a part which is already a revision'
)
})

@matmair matmair Jul 8, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C (non blocking): I think having trees of revisions would be helpful

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but having a potentially recursive relationship here makes it very hard to determine the total number of revisions for a part. This is why we utilize MPTT for the part variant - but we cannot have a second tree structure attached to the part model.

The limitation here is not too restrictive ( I think ) - as long as you point the "revision_of" to the same base part, you can have as many revisions as you like.

Feel free to suggest another approach!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think from a user perspective it is limiting as you need to manually re-structure multiple parts to achieve the same result. But I can see this taking a lot of effort to include in the PR.

Comment thread src/backend/InvenTree/part/models.py Resolved
Comment on lines +674 to +679
if self.revision_of.revision_of:
raise ValidationError({
'revision_of': _(
'Cannot make a revision of a part which is already a revision'
)
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think from a user perspective it is limiting as you need to manually re-structure multiple parts to achieve the same result. But I can see this taking a lot of effort to include in the PR.

@matmair

matmair commented Jul 10, 2024

Copy link
Copy Markdown
Member

@SchrodingersGat what is your opinion on my statement about the model structure? I can see this easily developing into something similar to reports/attachments where we duplicated code to multiple places for a generic function till we needed a refactor to simplify it back down.

@bberg115

Copy link
Copy Markdown

Sorry for the delayed response - I think the screen shots and the conversation above all seems good!

It's not something we've discussed, as far as I know, but how will this change effect the build order process? Will you be able to choose the revision of a BOM or be forced to latest?

@SchrodingersGat

Copy link
Copy Markdown
Member Author

@SchrodingersGat what is your opinion on my statement about the model structure? I can see this easily developing into something similar to reports/attachments where we duplicated code to multiple places for a generic function till we needed a refactor to simplify it back down.

It is a fair point. However at this stage, I can't see a clear delineation of which parts would be "generic" and which would be split into the separate model. Currently, I have created no new models, and this is a very simple change to "revert" if we need to. I would like to suggest that we wait until such time as we do want to add "revisions" to other models, and at that point, we make the effort to genericise the implementation. Until then, I'm not sure how we would implement it and we might have to refactor that anyway.

@SchrodingersGat

SchrodingersGat commented Jul 11, 2024 •

Copy link
Copy Markdown
Member Author

It's not something we've discussed, as far as I know, but how will this change effect the build order process? Will you be able to choose the revision of a BOM or be forced to latest?

@bberg115 not in this initial stage. Happy to discuss that as part of a future PR. There will likely be some other adjustments around revision management once people start using it.

@SchrodingersGat
SchrodingersGat merged commit 767b763 into inventree:master Jul 12, 2024
@SchrodingersGat
SchrodingersGat deleted the revision-of branch July 12, 2024 04:37
@SchrodingersGat

Copy link
Copy Markdown
Member Author

@bberg115 please feel free to raise any issues that you see with this new implementation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This is an suggested enhancement or new feature part Related to Part models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Roadmap] Implement proper revision system

4 participants