-
-
Notifications
You must be signed in to change notification settings - Fork 319
[16.0][ADD] sms_alternative_provider, sms_messagebird #327
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
base: 16.0
Are you sure you want to change the base?
Conversation
|
@sebastienbeau This is an attempt to produce something a step up from what you have done with |
|
another discussion point: Given that basically all modules that mess with sms at all override sms.api#_send_sms_batch and/or sms.sms#_postprocess_iap_sent_sms, it's crucial that the overrides of sms_alternative_provider come after any other override. I'm of a mind to patch into loading the module graph and inject a dependency on sms_alternative_provider for every module that depends on sms if sms_alternative_provider is installed. Do you agree, or should we leave this to glue modules to be done on a per case basis? |
I'm not quite sure of this TBH: let's say someone wanted to use That's not a very likely scenario, but in other cases, if I would override Could you give an example use case where someone would want this? |
|
sms_ovh_http works in both cases, so that's not a good example. sms_masked_content would have a problem, but that's handled accidentally right because modules on the same level (=same dependencies, both depend just on sms) are sorted alphabetically. So if you had another module also just depending on sms, but named |
|
Ah... right. Yes. Well your dependency idea does sound like a nice solution, so IMO you can go for it! |
|
ja hmm, i didn't think this through: at the point we can patch something, a module that we want to depend on ours might already be loaded, meaning its overrides are already incorporated into the models in the registry (odoo doesn't load the python code any more before actually loading the module). So we'd have to rebuild those models, remove the module from the module graph and have it reloaded afterwards. that's a very heavy operation for a theoretical problem, so I suggest we stash this idea for now. |
thomaspaulb
left a comment
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.
As for me I'm happy with the way it is now, we can work with it.
| actual_iap_results.extend(results) | ||
| else: | ||
| provider._handle_results( | ||
| [], results, unlink_failed=unlink_failed, unlink_sent=unlink_sent |
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.
Hey, the message dicts are not passed here,
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.
there are none at this point, because this function is called in sms.sms#_send, which operates on sms.sms records, and those you can access via results[i]['id']
actually I don't understand any more why you requested having the message dicts passed here in the first place. If a provider wants to do provider-specific stuff, why wouldn't it do that in _send_$provider after sending? And note that whatever a provider wants to write on an sms.sms record, it can just add to its result dictionaries.
| return super()._send_sms_batch(messages) | ||
| return self.env["ir.sms.gateway"]._send( | ||
| [dict(message, id=message.get("res_id")) for message in messages], | ||
| handle_results=False, |
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.
So in some cases, handle_results=False, which does not call handle_results directly after sending; instead it's being called from postprocess_iap_results, but then without the original message dicts.
What are the scenarios for having handle_results=True or False?
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.
we want to support just saying
self.env["ir.sms.gateway"]._send([some dicts, may or may not link to sms.sms records])
in which case the send function should call _handle_results, and here it shouldn't because _postprocess_iap_sent_sms does it. So this clumsiness is caused by this module trying to introduce a new kind of sms api, while staying compatible with overrides other modules might do for the original api. We could consider dropping this.
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
|
Applying no stale since I think this |
NL66278
left a comment
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.
👍 LGTM
|
/ocabot rebase |
|
Congratulations, PR rebased to 16.0. |
1738eb4 to
c8fdea9
Compare
as it potentially creates a new account in a new transaction, which will cause access errors when reading the account. cf https://github.com/OCA/OCB/blob/16.0/addons/iap/models/iap_account.py#L55
|
@thomaspaulb since OCA/OCB@851f83f the tests need another patch to succeed. Then the sms_ovh_http code only succeeds because it creates its own sms account, if that doesn't exist we run into https://github.com/OCA/OCB/blob/16.0/addons/iap/models/iap_account.py#L55 which returns an account from another transaction, causing accessing it afterwards to fail. So I think it's prudent anyways to test for existence there. If you agree with the latest two fixup commits, please give me the chance to squash commits before merging |
|
This PR has the |
This module allows configuring multiple providers for sending SMS.
By restricting providers to country or area codes, you can ie have Odoo pick different providers for different countries.