Skip to Content
Menu
This question has been flagged
2 Replies
1007 Views

I'm working on an Odoo app where I need to use a custom SMS provider for sending notifications, rather than the default SMS provider that Odoo typically uses. Most of the modules in Odoo seem to rely on the built-in SMS sender, and I’m unsure how to replace it with my custom provider.

Should I create an inherited model or method to override the default SMS sender behavior? Or is there a recommended approach to integrate custom SMS functionality in a way that works across forms and other modules? Any guidance or examples would be appreciated!

Avatar
Discard
Author

TypeError: Model 'sms.api' does not exist in registry.                  
this giving me this error

Best Answer

Hi Bahrom

The easiest way is to adapt SmsApi


class SmsApi(models.AbstractModel):
​_inherit = 'sms.api'
   _description = 'my API'

    @api.model
    def _send_sms(self, numbers, message):

        """ Send sms """

        my_api = call the calls of your new provider

        params = {
            'numbers': numbers,
            'message': message,
        }

        my_api.call(make the call)

        return True
# do the same  for _send_sms_batch



   I advise you to create the api calls as a seperate class that you can call


With this approach you ensure that all methods in odoo that calls the sms methods are calling your extension


From versio v17 odoo moved sms.api to a class to be used as 

from odoo.addons.sms.tools.sms_api import SmsApi

this means either you adapt the odoo class or the method using the class SmsApi



Hope this helps

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 25
288
2
Nov 22
1803
0
Nov 24
527
0
Oct 24
669
1
Oct 24
1041