Skip to content
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

635 openspp modules #702

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions spp_change_request/models/change_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,20 @@
for rec in self:
rec.request_type_ref_id._apply(rec)

def approve_cr(self):
"""
Approve the change request when the user is allowed to directly apply the changes.

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"):
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):
"""
Get and opens the wizard form change_request_cancel_wizard to cancel the change request
Expand Down Expand Up @@ -918,8 +932,6 @@
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
31 changes: 29 additions & 2 deletions spp_change_request/models/mixins/source_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
:raise ValidationError: Exception raised when something is not valid.
"""
self.ensure_one()
if self.env.context.get("skip_check_required_documents", False):
return

Check warning on line 115 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#L115

Added line #L115 was not covered by tests
self.check_required_documents()

def action_submit(self):
Expand Down Expand Up @@ -165,8 +167,7 @@
}
)
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 @@ -331,6 +332,32 @@
else:
raise ValidationError(_("The request must be in validated state for changes to be applied."))

def _approve_cr(self, request):
"""
Approve the change request directly.
"""
self.ensure_one()

Check warning on line 339 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#L339

Added line #L339 was not covered by tests
if request.state in ("draft", "pending", "validated"):
# Validate the submitted data
self.with_context(skip_check_required_documents=True).validate_data()

Check warning on line 342 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#L342

Added line #L342 was not covered by tests
# Apply Changes to Live Data
self.update_live_data()

Check warning on line 344 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#L344

Added line #L344 was not covered by tests
# Update CR record
addl_vals = {

Check warning on line 346 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#L346

Added line #L346 was not covered by tests
"applied_by_id": self.env.user,
"date_applied": fields.Datetime.now(),
"assign_to_id": None,
"state": "applied",
}
request.update(addl_vals)

Check warning on line 352 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#L352

Added line #L352 was not covered by tests
# Mark previous activity as 'done'
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:
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):
"""
This method is called when the Change Request is applied to the live data.
Expand Down
5 changes: 5 additions & 0 deletions spp_change_request/security/change_request_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<field name="category_id" ref="spp_change_request.spp_change_request_module" />
</record>

<record id="group_spp_change_request_external_api" model="res.groups">
<field name="name">Change Request External API</field>
<field name="category_id" ref="spp_change_request.spp_change_request_module" />
</record>

<record id="group_spp_change_request_local_validator" model="res.groups">
<field name="name">Change Request Validator Local</field>
<field name="category_id" ref="spp_change_request.spp_change_request_module" />
Expand Down
26 changes: 26 additions & 0 deletions spp_change_request/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,29 @@ spp_ir_sequence_agent,SPP IR Sequence Agent Access,base.model_ir_sequence,spp_ch
spp_change_request_cancel_wizard_agent,Change Request Cancel Agent Access,spp_change_request.model_spp_change_request_cancel_wizard,spp_change_request.group_spp_change_request_agent,1,1,1,1

spp_change_request_user_assign_wizard_agent,Change Request User Assignment Agent Access,spp_change_request.model_spp_change_request_user_assign_wizard,spp_change_request.group_spp_change_request_agent,1,1,1,0

spp_change_request_ext_api,Change Request External API Access,spp_change_request.model_spp_change_request,spp_change_request.group_spp_change_request_external_api,1,1,0,0
spp_change_request_validators_ext_api,Change Request Validators External API Access,spp_change_request.model_spp_change_request_validators,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_validation_sequence_ext_api,Change Request Validation Sequence External API Access,spp_change_request.model_spp_change_request_validation_sequence,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_validation_stage_ext_api,Change Request Validation Stage External API Access,spp_change_request.model_spp_change_request_validation_stage,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_group_members_ext_api,Change Request Group Membership External API Access,spp_change_request.model_spp_change_request_group_members,spp_change_request.group_spp_change_request_external_api,1,1,1,1
spp_change_request_user_assign_wizard_ext_api,Change Request User Assignment External API Access,spp_change_request.model_spp_change_request_user_assign_wizard,spp_change_request.group_spp_change_request_external_api,1,1,1,1
spp_change_request_reject_wizard_ext_api,Change Request Reject External API Access,spp_change_request.model_spp_change_request_reject_wizard,spp_change_request.group_spp_change_request_external_api,1,1,1,1
spp_change_request_area_ext_api,SPP-CR Area External API Access,spp_area.model_spp_area,spp_change_request.group_spp_change_request_external_api,1,0,0,0
spp_change_request_service_point_ext_api,SPP-CR Service Point External API Access,spp_service_points.model_spp_service_point,spp_change_request.group_spp_change_request_external_api,1,0,0,0
spp_change_request_g2p_group_membership_ext_api,G2P Group Membership External API Access,g2p_registry_membership.model_g2p_group_membership,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_g2p_group_membership_kind_ext_api,G2P Group Membership Kind External API Access,g2p_registry_membership.model_g2p_group_membership_kind,spp_change_request.group_spp_change_request_external_api,1,0,0,0
spp_change_request_g2p_reg_rel_ext_api,G2P Registry Relationship CR External API Access,g2p_registry_base.model_g2p_reg_rel,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_g2p_phone_number_ext_api,G2P Phone Number CR External API Access,g2p_registry_base.model_g2p_phone_number,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_g2p_reg_id_ext_api,G2P Registrant ID CR External API Access,g2p_registry_base.model_g2p_reg_id,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_change_request_cancel_wizard_ext_api,Change Request Cancel External API Access,spp_change_request.model_spp_change_request_cancel_wizard,spp_change_request.group_spp_change_request_external_api,1,1,1,1
spp_change_request_targets_ext_api,Change Request Targets External API Access,spp_change_request.model_spp_change_request_targets,spp_change_request.group_spp_change_request_external_api,1,1,1,0

spp_dms_directory_ext_api,SPP DMS Directory External API Access,spp_dms.model_spp_dms_directory,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_dms_category_ext_api,SPP DMS Category External API Access,spp_dms.model_spp_dms_category,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_dms_file_ext_api,SPP DMS File External API Access,spp_dms.model_spp_dms_file,spp_change_request.group_spp_change_request_external_api,1,1,1,1

spp_res_partner_ext_api,SPP Contacts External API Access,base.model_res_partner,spp_change_request.group_spp_change_request_external_api,1,1,1,0
spp_ir_model_ext_api,SPP IR Model External API Access,base.model_ir_model,spp_change_request.group_spp_change_request_external_api,1,0,0,0
spp_ir_model_fields_ext_api,SPP IR Model Fields External API Access,base.model_ir_model_fields,spp_change_request.group_spp_change_request_external_api,1,0,0,0
spp_ir_sequence_ext_api,SPP IR Sequence External API Access,base.model_ir_sequence,spp_change_request.group_spp_change_request_external_api,1,1,1,0
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
spp_change_request_add_children_demo_admin,Change Request Demo Type:Add Children Admin Access,spp_change_request_add_children_demo.model_spp_change_request_add_children,g2p_registry_base.group_g2p_admin,1,1,1,1

spp_change_request_add_children_demo_ext_api,Change Request Demo Type:Add Children External API Access,spp_change_request_add_children_demo.model_spp_change_request_add_children,spp_change_request.group_spp_change_request_external_api,1,1,1,1

spp_change_request_add_children_demo_registrar,Change Request Demo Type:Add Children Registrar Access,spp_change_request_add_children_demo.model_spp_change_request_add_children,g2p_registry_base.group_g2p_registrar,1,0,0,0

spp_change_request_add_children_demo_validator,Change Request Demo Type:Add Children Validator Access,spp_change_request_add_children_demo.model_spp_change_request_add_children,spp_change_request.group_spp_change_request_validator,1,1,0,0
Expand Down
Loading