Navigation

    Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

    开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

    如果您登录系统碰到问题,请在微信公众号留言:

    OpenERP的短信(SMS)接口

    Odoo 开发与实施交流
    8
    11
    11028
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      NewZN last edited by

      今天测试了一下OpenERP的短信(SMS)接口。
      在OpenERP的Partner界面上,WebClient的右边的工具条有个“send sms”的按钮。OpenERP中发短信用的是短信的Web接口,国内有很多提供Web接口的短信群发公司。OpenERP短信发送相关的代码在bin\tools\misc.py中:

      <br />def sms_send(user, password, api_id, text, to):<br />&nbsp; &nbsp; import urllib<br />&nbsp; &nbsp; url = &quot;http://api.urlsms.com/SendSMS.aspx&quot;<br />&nbsp; &nbsp; #url = &quot;http://196.7.150.220/http/sendmsg&quot;<br />&nbsp; &nbsp; params = urllib.urlencode({&#039;UserID&#039;: user, &#039;Password&#039;: password, &#039;SenderID&#039;: api_id, &#039;MsgText&#039;: text, &#039;RecipientMobileNo&#039;:to})<br />&nbsp; &nbsp; f = urllib.urlopen(url+&quot;?&quot;+params)<br />&nbsp; &nbsp; # FIXME: Use the logger if there is an error<br />&nbsp; &nbsp; return True<br />
      



      该段代码中写死了短信发送的URL代码,要在国内使用,必须修改成国内的短信发送URL。我测试了青岛维泰(http://www.waytide.com/html/index.htm)的Web短信平台。上他们的网页,和他们的客服联系,他们就会帮忙开通帐号,并赠送10条测试短信。使用青岛维泰的接口,上述代码要做如下修改:

      <br />def sms_send(user, password, api_id, text, to):<br />&nbsp; &nbsp; import urllib<br />&nbsp; &nbsp; url = &quot;http://www.msc8.cn/cgi/sendsmsbatch.asp&quot;<br />&nbsp; &nbsp; #url = &quot;http://196.7.150.220/http/sendmsg&quot;<br />&nbsp; &nbsp; params = urllib.urlencode({&#039;User&#039;: user, &#039;Pass&#039;: password, &#039;Mobile&#039;: to, &#039;Text&#039;: text})<br />&nbsp; &nbsp; f = urllib.urlopen(url+&quot;?&quot;+params)<br />&nbsp; &nbsp; import re<br />&nbsp; &nbsp; p=re.compile(&#039;^200 &#039;)<br />&nbsp; &nbsp; if p.match(res):&nbsp; #send OK!<br />&nbsp; &nbsp; &nbsp; &nbsp; netsvc.Logger().notifyChannel(&#039;SMS_send&#039;, netsvc.netsvc.LOG_DEBUG, f.read())<br />&nbsp; &nbsp; else:<br />&nbsp; &nbsp; &nbsp; &nbsp; netsvc.Logger().notifyChannel(&#039;SMS_send&#039;, netsvc.netsvc.LOG_ERROR, f.read())<br />&nbsp; &nbsp; # FIXME: Use the logger if there is an error<br />&nbsp; &nbsp; return True<br />
      



      青岛维泰的接口中,可以用逗号隔开,输入多个手机号码。上述代码中,增加了一段检查短信发送是否成功的代码,发送成功应该返回“200 ”开头的一段文字,如果发送失败,将在OpenERP的Log中记录错误信息。

      另外,为了处理汉字(gb2312),server\addons\base\res\partner\wizard\wizard_sms.py下的方法_sms_send 也要修改一下。
      原文:tools.sms_send(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('latin1'), to)
      改成:tools.sms_send(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('gb2312'), to)

      1 Reply Last reply Reply Quote 0
      • mrshelly
        mrshelly last edited by

        打击 软广告....

        1 Reply Last reply Reply Quote 0
        • D
          dquo last edited by

          怎么也得免费使用3个月呀,才10条

          1 Reply Last reply Reply Quote 0
          • W
            winson97 last edited by

            学习了!
            论坛没有收藏功能?

            1 Reply Last reply Reply Quote 0
            • C
              CnBoYer last edited by

              mark一下  专门来老肖的贴,最近在摸索OE的CRM相关模块

              1 Reply Last reply Reply Quote 0
              • H
                hifly last edited by

                if p.match(res):  #send OK!
                res是什么啊?

                1 Reply Last reply Reply Quote 0
                • mrshelly
                  mrshelly last edited by

                  [quote author=hifly link=topic=2139.msg9106#msg9106 date=1324446615]
                  if p.match(res):  #send OK!
                  res是什么啊?
                  [/quote]

                  是 NameError: name 'res' is not defined

                  1 Reply Last reply Reply Quote 0
                  • T
                    tubage last edited by

                    服务器动作要安装smsclient这个模块,去这里找http://doc.openerp.com/v6.0/technical_guide/

                    1 Reply Last reply Reply Quote 0
                    • H
                      hifly last edited by

                      谢谢shelly的回复  🙂

                      1 Reply Last reply Reply Quote 0
                      • R
                        rufeng1199 last edited by

                        确信无疑  软广告,呵呵

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post