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账号

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

    修改发件人(SMTP)服务器为用户个人配置(已增加模块地址)

    Odoo 开发与实施交流
    2
    4
    4041
    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.
    • C
      ccloolcc last edited by

      2013-07-25  制作成模块 下载地址 https://github.com/ccloolcc/sent-email-by-user-config br />由于还不太明白重载的写法,所以直接拷贝的原方法的所有代码,新手轻喷。


      需求:openerp所有外发邮件改用每个用户自行配置的邮箱账户进行发送(smtp服务器是同一台且邮箱域名相同)。

      1. 设置——数据结构——字段,创建一个字段模型选择res.user,字段类型为char
      2. 设置——用户界面——视图,搜索res.users.preferences.form(由于我只想在首选项里看见这个input,所以只改了这个视图),找喜欢的位置添加代码<field name="刚才创建的字段名" password="1"/>(password="1"这里获得了mrshelly大神的帮助,在此鸣谢)
      3. 打开文件addons/base/ir/ir_mail_server.py,在441行后添加代码段如下:

          smtp_user = smtp_from  #邮箱账户强制改成发件人,有点粗暴。注意,这里的smtp_from是别名,并不是用户看见的那个邮箱。据此推断写成下边这样应该更方便。
          #smtp_user = self.pool.get('res.users').browse(cr, uid, uid, context=context).email
          smtp_password = self.pool.get('res.users').browse(cr, uid, uid, context=context).刚才创建的字段名


      我知道我的方法有些粗暴,后续如果官方有升级的话会很麻烦。所以希望有大神可以指点下这样的模块要怎么开发。我在网上搜了模块开发的教程,不过都是新模块,没有设计到对老模块的修改和补充的模块,所以也比较没头绪 😞


      PS:刚才调试了一下获取res.users.email的代码,最终发现email字段根本不存在users表中而是在partner这个表里,所以修改获取smtp_user的代码如下:
          pid = self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id._id
          smtp_user = self.pool.get('res.partner').browse(cr, uid, pid, context=context).email

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

        https://github.com/ccdos/into-openerp-addons/tree/master/auto_select_smtp

        自动选择合适的 smtp

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

          [quote author=ccdos link=topic=7412.msg16950#msg16950 date=1373476516]<br / https://github.com/ccdos/into-openerp-addons/tree/master/auto_select_smtp br />
          自动选择合适的 smtp
          [/quote]


          多谢ccdos的模块,需求上还不太合用,不过学习到了方法重载。

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