Skip to content

[Mig] sms_alternative_provider #355

Closed
bjouini-acsone wants to merge 8 commits intoOCA:18.0from
acsone:mig-sms_alternative_provider-18.0-bjo
Closed

[Mig] sms_alternative_provider #355
bjouini-acsone wants to merge 8 commits intoOCA:18.0from
acsone:mig-sms_alternative_provider-18.0-bjo

Conversation

@bjouini-acsone
Copy link

@bjouini-acsone bjouini-acsone commented Nov 14, 2025

this is a partial migration of the Pr:#327 on v16

the major changements from v16 to 18:
the sms_api model does not exist anymore
on the previous implementation , if we found None passede we use the custom logic that we add , but in v18 if we pass None to the send method we always use the standard behaviour of odoo , this is why it is changed in this version

Copy link

@qgroulard qgroulard left a comment

Choose a reason for hiding this comment

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

Hi, this is an attempt at reviewing this PR but:

  1. I'm not really comfortable with this topic
  2. I think it's lacking a lot of explanation

To ease the review, could you please:

  1. Squash your 2 migration commits
  2. Minimize the diff as much as possible, i.e. push only relevant changes. Please don't remove still accurate docstrings, reword working code, etc. Unless it really improves the code of course.
  3. Provide explanation on the key changes. Please make use of the "description" section of this PR. Such a big PR should be heavily documented, not pushed with an empty description.

Once this PR is nice and clean, hopefully we can get the help of @hbrunn to get it reviewed and merged 👍

Comment on lines 51 to 55
Return list of dictionaries [{
'id': sms.sms id,
'state': sms.sms#state,
'failure_type': sms.sms#failure_type
'uuid': sms.sms uuid,
'state': sms state,
'failure_reason': optional failure reason
}]

Choose a reason for hiding this comment

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

We still return "id" as well.

["|", ("company_id", "=", False), ("company_id", "=", self.env.company.id)]
providers = self.search(
[
("active", "=", True),

Choose a reason for hiding this comment

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

I don't think adding ("active", "=", True) has any effect here.

Comment on lines 128 to 129
sms_records = SmsSms.browse([msg["id"] for msg in messages_to_send])
provider_result = gateway._send_via_self(sms_records) or []

Choose a reason for hiding this comment

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

Could you please explain why you need to browse the sms record before calling _send_via_self() now ?

Comment on lines 156 to 194
def _send_partition_providers(self, messages):
"""
Return a dict with providers in self as keys and lists of messages a provider
will handle as value
ie
{
ir.gateway.record(42,): [{message1}, {message2}],
ir.gateway.record(43,): [{message3}],
ir.gateway.record(44,): [],
ir.gateway.record(): [{messages not handled by any available provider}],
}
"""
result = {}
remaining_messages = messages[:]

# Sort providers by sequence (priority)
sorted_providers = self.sorted(key=lambda p: p.sequence)
_logger.info(
"Sorted providers by sequence: %s",
[(p.name, p.sequence) for p in sorted_providers],
)

while remaining_messages:
message = remaining_messages.pop()
for this in self:
if this._can_send(message):
result.setdefault(this, []).append(message)
assigned = False
for provider in sorted_providers:
can_send = provider._can_send(message)
_logger.info(
"Provider %s can send to %s: %s",
provider.name,
message.get("number"),
can_send,
)
if can_send:
result.setdefault(provider, []).append(message)
assigned = True
_logger.info(
"Assigned message %s to provider %s",
message.get("id"),
provider.name,
)
break
else:
if not assigned:
result.setdefault(self.browse([]), []).append(message)
_logger.info("No provider found for message %s", message.get("id"))
return result

Choose a reason for hiding this comment

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

In general, could you please try to minimize the diff by avoiding unnecessary changes.

For instance here I don't understand the change in the docstring.
Also the model ir.sms.gateway is ordered by sequence, thus I don't understand the sort you are adding.
Finally, how is different the use of your variable assigned from the previous for else ?

@bjouini-acsone bjouini-acsone force-pushed the mig-sms_alternative_provider-18.0-bjo branch 8 times, most recently from d4c982b to e3ff947 Compare November 19, 2025 14:09
@yvaucher
Copy link
Member

Overseeded by #360

@yvaucher yvaucher closed this Feb 10, 2026
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