Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1048 Vistas

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

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

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 25
301
2
nov 22
1832
0
nov 24
557
0
oct 24
707
1
oct 24
1113