Skip to content

Commit

Permalink
Merge pull request #233 from RamakrishnaVellala/15.0-develop-main
Browse files Browse the repository at this point in the history
G2p-2063, 2133, 2375 bug fixes
  • Loading branch information
shibu-narayanan authored Jun 5, 2024
2 parents 0265994 + b47b185 commit 0cb4786
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions g2p_programs/wizard/assign_to_program_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def assign_registrant(self):
for rec in self.env["res.partner"].search([("id", "in", partner_ids)]):
if self.program_id not in rec.program_membership_ids.program_id:
ctr += 1
_logger.debug("Processing (%s): %s" % (ctr, rec.name))
_logger.debug(f"Processing ({ctr}): {rec.name}")
proceed = False
# Do not include disabled registrants
if rec.disabled:
ig_ctr += 1
ctr -= 1
_logger.debug("Ignored because registrant is disabled: %s" % rec.name)
else:
if rec.is_group: # Get only group registrants
Expand Down Expand Up @@ -81,12 +81,11 @@ def assign_registrant(self):
else:
ig_ctr += 1
_logger.debug(
"%s was ignored because the registrant is already in the Program %s"
% (rec.name, self.program_id.name)
f"{rec.name} was ignored because the registrant is already in the Program"
f"{self.program_id.name}"
)
_logger.debug(
"Total selected registrants:%s, Total ignored:%s, Total added to group:%s"
% (ctr, ig_ctr, ok_ctr)
f"Total selected registrants:{ctr}, Total ignored:{ig_ctr}, Total added to group:{ok_ctr}"
)

if len(partner_ids) == 1:
Expand All @@ -96,17 +95,31 @@ def assign_registrant(self):
"program": self.program_id.name,
}
kind = "danger"
if ig_ctr and not rec.disabled:
elif ig_ctr and not rec.disabled:
message = _("%(registrant)s was already in the Program %(program)s") % {
"registrant": rec.name,
"program": self.program_id.name,
}
kind = "danger"
else:
message = _("%(registrant)s is added to the Program %(program)s") % {
"registrant": rec.name,
"program": self.program_id.name,
}
kind = "warning"

else:
if not ctr:
if not ctr and not rec.disabled:
message = _("Registrant's was already in the Program %s") % self.program_id.name
kind = "danger"

elif not ctr and rec.disabled and rec.is_group:
message = _("Disabled group(s) can't be added to the program %s") % self.program_id.name
kind = "danger"
elif not ctr and rec.disabled and not rec.is_group:
message = (
_("Disabled Individual(s) can't be added to the program %s") % self.program_id.name
)
kind = "danger"
else:
message = _(
"Total registrants:%(total)s, Already in program:%(existing)s, Newly added:%(new)s"
Expand All @@ -129,7 +142,6 @@ def assign_registrant(self):
}

def open_wizard(self):

# _logger.debug("Registrant IDs: %s" % self.env.context.get("active_ids"))
return {
"name": "Add to Program",
Expand Down

0 comments on commit 0cb4786

Please sign in to comment.