-
-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] Addon: project_required_field_by_stage #1341
base: 16.0
Are you sure you want to change the base?
Conversation
0afd8b1
to
e0829bc
Compare
e0829bc
to
8e2d9a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional review, LGTM.
if hasattr(self, "%s" % field.name): | ||
if not getattr(self, "%s" % field.name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if hasattr(self, "%s" % field.name): | |
if not getattr(self, "%s" % field.name): | |
if hasattr(rec, field.name) and not getattr(rec, field.name): |
for rec in self: | ||
stage = self.env["project.task.type"].search([("id", "=", rec.stage_id.id)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can only go through the stages that have required fields assigned.
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 |
This PR add the module
project_required_field_by_stage
that 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.