Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1061 Представления

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!

Аватар
Отменить
Автор

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

Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
янв. 25
304
2
нояб. 22
1839
0
нояб. 24
559
0
окт. 24
716
1
окт. 24
1145