Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
1995 Ansichten

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
Verwerfen
Autor

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

Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Jan. 25
803
2
Nov. 22
2373
1
Juli 25
433
2
Juni 25
606
0
Nov. 24
1211