[16.0][ADD] Addon: project_required_field_by_stage#1341
Closed
[16.0][ADD] Addon: project_required_field_by_stage#1341
Conversation
0afd8b1 to
e0829bc
Compare
e0829bc to
8e2d9a3
Compare
gbrito
suggested changes
Nov 13, 2024
Comment on lines
+65
to
+66
| if hasattr(self, "%s" % field.name): | ||
| if not getattr(self, "%s" % field.name): |
There was a problem hiding this comment.
Suggested change
| if hasattr(self, "%s" % field.name): | |
| if not getattr(self, "%s" % field.name): | |
| if hasattr(rec, field.name) and not getattr(rec, field.name): |
Comment on lines
+56
to
+57
| for rec in self: | ||
| stage = self.env["project.task.type"].search([("id", "=", rec.stage_id.id)]) |
There was a problem hiding this comment.
maybe you can only go through the stages that have required fields assigned.
Suggested change
| for rec in self: | |
| stage = self.env["project.task.type"].search([("id", "=", rec.stage_id.id)]) | |
| stages = self.stage_id.filtered(lambda x: x.required_field_ids) | |
| for stage in stages: | |
| fields = ( | |
| self.env["ir.model.fields"] | |
| .sudo() | |
| .search([("id", "in", stage.required_field_ids.ids)]) | |
| ) | |
| for rec in self.filtered(lambda x: x.stage_id == stage): | |
| for field in fields: | |
| if hasattr(rec, field.name) and not getattr(rec, field.name): | |
| raise error |
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR add the module
project_required_field_by_stagethat allow to define required fields depending on the stage of the task.NOTE: I was unable to find a satisfactory way to cover lines 30-33 and 35-37 of the models/project_task.py file with tests, I accept suggestions.