Skip to content

Commit

Permalink
Fix issues raised in PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalesedwin1123 committed Nov 28, 2024
1 parent 7f2f5aa commit 5ea10c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 2 additions & 3 deletions spp_change_request/models/change_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,11 +857,12 @@ def approve_cr(self):
Usage:
- Call this function via XMLRPC
:raise ValidationError: Exception raised when user is allowed to directly approve the CR.
"""
self.ensure_one()

Check warning on line 862 in spp_change_request/models/change_request.py

View check run for this annotation

Codecov / codecov/patch

spp_change_request/models/change_request.py#L862

Added line #L862 was not covered by tests
# Check if user is allowed to directly approve the CR
if not self.env.user.has_group("spp_change_request.group_spp_change_request_external_api"):
ValidationError("User is not allowed to approve CRs directly.")
raise ValidationError(_("User is not allowed to approve CRs directly."))
return self.request_type_ref_id._approve_cr(self)

Check warning on line 866 in spp_change_request/models/change_request.py

View check run for this annotation

Codecov / codecov/patch

spp_change_request/models/change_request.py#L865-L866

Added lines #L865 - L866 were not covered by tests

def action_cancel(self):
Expand Down Expand Up @@ -931,8 +932,6 @@ def action_reset_to_draft(self):
name="action_reset_to_draft"
type="object"
/>
:raise ValidationError: Exception raised when something is not valid.
"""
for rec in self:
rec.request_type_ref_id._reset_to_draft(rec)
Expand Down
4 changes: 0 additions & 4 deletions spp_change_request/models/dms_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ class SPPDMSFileCustom(models.Model):

change_request_id = fields.Many2one("spp.change.request", "Change Request")

def create(self, vals):
# _logger.info("DEBUG vals: %s", vals)
return super().create(vals)

def action_save_and_close(self):
return {"type": "ir.actions.act_window_close"}

Expand Down
7 changes: 4 additions & 3 deletions spp_change_request/models/mixins/source_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ def _on_submit(self, request):
}
)
else:
# TODO: @edwin Should we use UserError or ValidationError?
raise UserError(_("The request must be in draft state to be set to pending validation."))
raise ValidationError(_("The request must be in draft state to be set to pending validation."))

Check warning on line 170 in spp_change_request/models/mixins/source_mixin.py

View check run for this annotation

Codecov / codecov/patch

spp_change_request/models/mixins/source_mixin.py#L170

Added line #L170 was not covered by tests

def action_validate(self):
"""
Expand Down Expand Up @@ -355,7 +354,9 @@ def _approve_cr(self, request):
request.last_activity_id.action_done()
return {"success": _("The change request has been approved.")}

Check warning on line 355 in spp_change_request/models/mixins/source_mixin.py

View check run for this annotation

Codecov / codecov/patch

spp_change_request/models/mixins/source_mixin.py#L354-L355

Added lines #L354 - L355 were not covered by tests
else:
ValidationError("The request must be in draft, pending, or validated state for changes to be applied.")
raise ValidationError(

Check warning on line 357 in spp_change_request/models/mixins/source_mixin.py

View check run for this annotation

Codecov / codecov/patch

spp_change_request/models/mixins/source_mixin.py#L357

Added line #L357 was not covered by tests
_("The request must be in draft, pending, or validated state for changes to be applied.")
)

def action_cancel(self):
"""
Expand Down

0 comments on commit 5ea10c6

Please sign in to comment.