Repository navigation
Revision Improvements - #7585
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bumps [djangorestframework](https://github.com/encode/django-rest-framework) from 3.14.0 to 3.15.2. - [Release notes](https://github.com/encode/django-rest-framework/releases) - [Commits](encode/django-rest-framework@3.14.0...3.15.2) --- updated-dependencies: - dependency-name: djangorestframework dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]>
matmair
left a comment
There was a problem hiding this comment.
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
Partmodel (and future ones like Orders, Stock, ...) that adds arevision_ofand arevisionFK field - a generic
Revisionmodel 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.
| if self.revision_of.revision_of: | ||
| raise ValidationError({ | ||
| 'revision_of': _( | ||
| 'Cannot make a revision of a part which is already a revision' | ||
| ) | ||
| }) |
There was a problem hiding this comment.
C (non blocking): I think having trees of revisions would be helpful
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
| if self.revision_of.revision_of: | ||
| raise ValidationError({ | ||
| 'revision_of': _( | ||
| 'Cannot make a revision of a part which is already a revision' | ||
| ) | ||
| }) |
There was a problem hiding this comment.
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.
|
@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. |
|
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? |
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. |
@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. |
|
@bberg115 please feel free to raise any issues that you see with this new implementation :) |

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
revision_offield to thePartmodelTODO
Screenshots
The "revision selector" dropdown appears for parts where there are multiple revisions available:
Clicking on a particular revision takes you to that revision.
looking for feedback at this stage, before progressing much further.
@matmair @wolflu05 @bberg115