-
Notifications
You must be signed in to change notification settings - Fork 0
fix(spp_programs): reliably close wizard modal after program creation #15
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
Open
emjay0921
wants to merge
3
commits into
19.0
Choose a base branch
from
fix/spp-programs-wizard-modal-close
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a0367eb
fix(spp_programs): reliably close wizard modal after program creation
emjay0921 5354362
fix(spp_programs): hide Geographic Targeting from Eligibility Manager UI
emjay0921 dd8d38d
fix(spp_programs): pass translated name and view_id to client action
emjay0921 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,72 +366,73 @@ def _insert_domain_operator(self, domain): | |
| return new_domain | ||
|
|
||
| def create_program(self): | ||
| self.ensure_one() | ||
| self._check_required_fields() | ||
| for rec in self: | ||
| program_vals = rec.get_program_vals() | ||
| program = self.env["spp.program"].with_context(skip_default_managers=True).create(program_vals) | ||
|
|
||
| program_id = program.id | ||
| vals = {} | ||
| program_vals = self.get_program_vals() | ||
| program = self.env["spp.program"].with_context(skip_default_managers=True).create(program_vals) | ||
|
|
||
| # Set Default Eligibility Manager settings | ||
| vals.update(rec._get_eligibility_manager(program_id)) | ||
| program_id = program.id | ||
| vals = {} | ||
|
|
||
| # Set Default Cycle Manager settings | ||
| # Add a new record to default cycle manager model | ||
| # Set Default Eligibility Manager settings | ||
| vals.update(self._get_eligibility_manager(program_id)) | ||
|
|
||
| cycle_manager_default_val = rec.get_cycle_manager_default_val(program_id) | ||
| def_mgr = self.env["spp.cycle.manager.default"].create(cycle_manager_default_val) | ||
| # Set Default Cycle Manager settings | ||
| # Add a new record to default cycle manager model | ||
|
|
||
| # Add a new record to cycle manager parent model | ||
| cycle_manager_default_val = self.get_cycle_manager_default_val(program_id) | ||
| def_mgr = self.env["spp.cycle.manager.default"].create(cycle_manager_default_val) | ||
|
|
||
| cycle_manager_val = rec.get_cycle_manager_val(program_id, def_mgr) | ||
| mgr = self.env["spp.cycle.manager"].create(cycle_manager_val) | ||
| # Add a new record to cycle manager parent model | ||
|
|
||
| vals.update({"cycle_manager_ids": [(4, mgr.id)]}) | ||
| cycle_manager_val = self.get_cycle_manager_val(program_id, def_mgr) | ||
| mgr = self.env["spp.cycle.manager"].create(cycle_manager_val) | ||
|
|
||
| # Set Default Entitlement Manager | ||
| vals.update(rec._get_entitlement_manager(program_id)) | ||
| vals.update({"cycle_manager_ids": [(4, mgr.id)]}) | ||
|
|
||
| # Set Default Program Manager | ||
| vals.update(rec._get_program_manager(program_id)) | ||
| # Set Default Entitlement Manager | ||
| vals.update(self._get_entitlement_manager(program_id)) | ||
|
|
||
| # Clean legacy aliases that are not real fields on spp.program | ||
| vals.pop("eligibility_managers", None) | ||
| vals.pop("cycle_managers", None) | ||
| # Convert legacy entitlement_managers key to entitlement_manager_ids | ||
| if "entitlement_managers" in vals: | ||
| entitlement_managers = vals.pop("entitlement_managers") | ||
| if "entitlement_manager_ids" not in vals: | ||
| vals["entitlement_manager_ids"] = entitlement_managers | ||
| # Set Default Program Manager | ||
| vals.update(self._get_program_manager(program_id)) | ||
|
|
||
| vals.update({"is_one_time_distribution": rec.is_one_time_distribution}) | ||
| # Clean legacy aliases that are not real fields on spp.program | ||
| vals.pop("eligibility_managers", None) | ||
| vals.pop("cycle_managers", None) | ||
| # Convert legacy entitlement_managers key to entitlement_manager_ids | ||
| if "entitlement_managers" in vals: | ||
| entitlement_managers = vals.pop("entitlement_managers") | ||
| if "entitlement_manager_ids" not in vals: | ||
| vals["entitlement_manager_ids"] = entitlement_managers | ||
|
|
||
| # Complete the program data | ||
| program.update(vals) | ||
| vals.update({"is_one_time_distribution": self.is_one_time_distribution}) | ||
|
|
||
| if rec.import_beneficiaries == "yes" or rec.is_one_time_distribution: | ||
| rec.program_wizard_import_beneficiaries(program) | ||
| # Complete the program data | ||
| program.update(vals) | ||
|
|
||
| if rec.is_one_time_distribution: | ||
| program.create_new_cycle() | ||
| if self.import_beneficiaries == "yes" or self.is_one_time_distribution: | ||
| self.program_wizard_import_beneficiaries(program) | ||
|
|
||
| view_id = self.env.ref("spp_programs.view_program_list_form") | ||
| if rec.view_id: | ||
| view_id = rec.view_id | ||
| if self.is_one_time_distribution: | ||
| program.create_new_cycle() | ||
|
|
||
| program.view_id = view_id.id | ||
| view_id = self.env.ref("spp_programs.view_program_list_form") | ||
| if self.view_id: | ||
| view_id = self.view_id | ||
|
|
||
| # Open the newly created program | ||
| return { | ||
| "name": _("Programs"), | ||
| "view_mode": "form", | ||
| "res_model": "spp.program", | ||
| "res_id": program_id, | ||
| program.view_id = view_id.id | ||
|
|
||
| # Close modal and open program form using client action with async/await | ||
| return { | ||
| "type": "ir.actions.client", | ||
| "tag": "open_program_close_modal", | ||
| "params": { | ||
| "program_id": program_id, | ||
| "name": _("Program"), | ||
| "view_id": view_id.id, | ||
| "type": "ir.actions.act_window", | ||
| "target": "current", | ||
| } | ||
| }, | ||
|
Comment on lines
430
to
434
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To support internationalization and allow for specific form views, it's a good practice to pass the translated window name and the calculated "params": {
"program_id": program_id,
"name": _("Program"),
"view_id": view_id.id,
}, |
||
| } | ||
|
|
||
| def _get_default_eligibility_manager_val(self, program_id): | ||
| return { | ||
|
|
||
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
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
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
Oops, something went wrong.
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.
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.
The
nameof the action window is hardcoded as "Program", which isn't translatable. Also, theviewsparameter is hardcoded to use the default form view ([[false, "form"]]), which differs from the previous implementation that allowed a specificview_idto be used. To improve internationalization and restore the original flexibility, consider passing thenameandview_idfrom the server-side action's parameters.