Skip to content

[UPG] spp_sms: upgrade spp_sms to 17.0 #785

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
wants to merge 25 commits into
base: 17.0
Choose a base branch
from

Conversation

reichie020212
Copy link
Member

Why is this change needed?

spp_sms module is still in another repo and is still in 15.0

How was the change implemented?

Moved the spp_sms module to this repo and migrated it to 17.0

New unit tests

Unit tests executed by the author

How to test manually

Related links

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 90.02268% with 44 lines in your changes missing coverage. Please review.

Project coverage is 76.00%. Comparing base (d840c60) to head (6ec4f45).
Report is 8 commits behind head on 17.0.

Files with missing lines Patch % Lines
spp_sms/models/iap_account.py 40.42% 28 Missing ⚠️
spp_sms/models/mailing_mailing.py 91.56% 1 Missing and 6 partials ⚠️
spp_sms/tools/sms_api.py 73.07% 7 Missing ⚠️
spp_sms/tests/test_mailing_mailing.py 98.56% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             17.0     #785      +/-   ##
==========================================
+ Coverage   75.67%   76.00%   +0.32%     
==========================================
  Files         764      778      +14     
  Lines       20218    20659     +441     
  Branches     2501     2541      +40     
==========================================
+ Hits        15300    15701     +401     
- Misses       4382     4416      +34     
- Partials      536      542       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@gonzalesedwin1123 gonzalesedwin1123 left a comment

Choose a reason for hiding this comment

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

@reichie020212 please check the codecov report.

@gonzalesedwin1123 gonzalesedwin1123 self-requested a review March 31, 2025 01:21
Copy link
Member

@gonzalesedwin1123 gonzalesedwin1123 left a comment

Choose a reason for hiding this comment

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

@reichie020212 check also the sonarqubecloud report.

@OpenSPP OpenSPP deleted a comment from github-actions bot Mar 31, 2025
Copy link

github-actions bot commented Mar 31, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@megaxayda
Copy link

I have read the CLA Document and I hereby sign the CLA

openspp-bot added a commit to OpenSPP/openspp-cla that referenced this pull request Mar 31, 2025
@megaxayda megaxayda self-assigned this Apr 2, 2025
@kneckinator kneckinator self-requested a review April 2, 2025 06:51
@kneckinator kneckinator requested review from Copilot and removed request for Copilot April 9, 2025 07:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 20 out of 28 changed files in this pull request and generated 2 comments.

Files not reviewed (8)
  • spp_sms/README.rst: Language not supported
  • spp_sms/i18n/ar.po: Language not supported
  • spp_sms/i18n/ckb.po: Language not supported
  • spp_sms/i18n/fr.po: Language not supported
  • spp_sms/i18n/spp_sms.pot: Language not supported
  • spp_sms/readme/DESCRIPTION.rst: Language not supported
  • spp_sms/security/ir.model.access.csv: Language not supported
  • spp_sms/static/description/index.html: Language not supported

elif self.mailing_registrant_type == "Program":
vals = []
for rec in self.mailing_program_ids:
vals = self._get_enrolled_members(rec.program_id, "program_id", "program_membership_ids")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we are not collecting all members in the for-loop and then making a single call to self._update_mailing_domain(vals)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done fixing this in local, not yet pushed.

main_record = getattr(rec, record_field)
for rec_line in getattr(main_record, membership_field):
if rec_line.state == "enrolled":
if rec_line.partner_id.is_group:
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not seem the handle the case of groups-of-groups?

Copy link
Member Author

Choose a reason for hiding this comment

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

@kneckinator yes since the groups-of-groups concept comes from the module spp_registry_group_hierarchy which is not being used by spp_sms module. spp_sms module only uses the module g2p_registry_base.

Copy link
Contributor

@kneckinator kneckinator Apr 11, 2025

Choose a reason for hiding this comment

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

So what happens if spp_sms is installed together with spp_registry_group_hierarchy and the user intends to send an SMS to the highest group level?

It operates on the entity that is enrolled into a program/cycle, and it is my understanding that a "group of groups" can be enrolled into a program/cycle. Thus, the system needs to present an error message at least and check that the partner_id has is_registrant set to True.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kneckinator I pushed a new commit to accomodate this.



def _send_sms_batch(self, messages, delivery_reports_url=False):
account = self.env["iap.account"].search([("active_status", "=", True)]).get("sms")
Copy link
Contributor

Choose a reason for hiding this comment

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

The account name can only be set before changing the provider from Odoo IAP to one of the SMS providers. The name field in the Account information is hidden when one of the SMS providers are selected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done fixing this. Added creation of data when installing spp_sms

def _send_sms_batch(self, messages, delivery_reports_url=False):
account = self.env["iap.account"].search([("active_status", "=", True)]).get("sms")

if not account or account[0].provider != "sms_twilio":
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this work if multiple active SMS accounts have been defined? Is there a default order_by to ensure that the same account is used everytime?
What if both SNS and Twilio accounts have been defined?

Can you provide a setting somewhere so the user can select a single account (or if we want, multiple accounts) that will be used to send the SMS? This will also avoid a query like SELECT * FROM .... WHERE active_status = "true" ... in the .search above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Added sequence field in the iap.account

@OpenSPP OpenSPP deleted a comment from Copilot AI Apr 11, 2025
@OpenSPP OpenSPP deleted a comment from Copilot AI Apr 11, 2025
"website": "https://github.com/OpenSPP/openspp-modules",
"license": "AGPL-3",
"depends": ["iap", "sms", "mass_mailing_sms", "g2p_registry_base", "g2p_programs"],
"development_status": "Beta",
Copy link
Contributor

Choose a reason for hiding this comment

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

Status should be alpha at this stage.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

error_messages = original_get_sms_api_error_messages(self)
error_messages["invalid_to_number"] = _("The number you're trying to reach is not correctly formatted.")
error_messages["invalid_from_number"] = _("The number you're trying to send from is not correctly formatted.")
error_messages["cannot_be_reached"] = _("The number you're trying to reach is not correctly formatted.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This message is misleading. The message means that the SMS Gateway cannot reach the phone number, and that it might be incorrect. Better error message: "The number cannot be reached. Please check the number."

See: https://www.twilio.com/docs/api/errors/21214

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

result.append({"state": state, "credit": 0, "res_id": number["number"]})
return result

# NOTE: Removing sns_amazon for now since boto3 is not compatible with the current version of urllib3
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this only mentioned here and not in the PR conversation? This is something we should solve. When you say current version of urllib3, which version are you referring to?

Copy link
Member Author

Choose a reason for hiding this comment

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

what i mean in this comment is the latest version. I haven't thoroughly investigating this since we're not using sms amazon. i'll try to dwell on this issue on a later time.

return result

# NOTE: Removing sns_amazon for now since boto3 is not compatible with the current version of urllib3
# elif account[0].provider == "sns_amazon":
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move all the AWS SNS-specific code to a separate function, i.e awssns_send_sms_batch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

account = self.env["iap.account"].search([("active_status", "=", True)]).get("sms")

if not account or account[0].provider != "sms_twilio":
return original_send_sms_batch(self, messages, delivery_reports_url)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this SMS batch function handle AWS SNS messages?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants