Skip to content

[16.0][ADD] Addon: project_required_field_by_stage#1341

Closed
Tiago370 wants to merge 1 commit intoOCA:16.0from
kmee:16.0-add-project_required_field_by_stage
Closed

[16.0][ADD] Addon: project_required_field_by_stage#1341
Tiago370 wants to merge 1 commit intoOCA:16.0from
kmee:16.0-add-project_required_field_by_stage

Conversation

@Tiago370
Copy link

@Tiago370 Tiago370 commented Sep 26, 2024

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.

@Tiago370 Tiago370 changed the title [ADD] Addon: project_required_field_by_stage [16.0][ADD] Addon: project_required_field_by_stage Sep 28, 2024
@Tiago370 Tiago370 force-pushed the 16.0-add-project_required_field_by_stage branch 12 times, most recently from 0afd8b1 to e0829bc Compare September 28, 2024 22:03
@Tiago370 Tiago370 force-pushed the 16.0-add-project_required_field_by_stage branch from e0829bc to 8e2d9a3 Compare September 28, 2024 22:28
@Tiago370 Tiago370 marked this pull request as ready for review September 28, 2024 22:37
Copy link

@gjotten gjotten left a comment

Choose a reason for hiding this comment

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

Functional review, LGTM.

Comment on lines +65 to +66
if hasattr(self, "%s" % field.name):
if not getattr(self, "%s" % field.name):
Copy link

Choose a reason for hiding this comment

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

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)])
Copy link

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.

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

@github-actions
Copy link

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.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 16, 2025
@github-actions github-actions bot closed this Apr 20, 2025
@gfcapalbo
Copy link
Contributor

@gbrito this MR was re-created here: #1650 , your review suggestions were implemented there.

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

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants