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

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

    如何获取指定用户的指针并取得email值

    Odoo 开发与实施交流
    2
    6
    3291
    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.
    • J
      jerry79 last edited by

      目前想要实现一个简单的功能,即主管分配某项工作给员工。
      class里面有两个值,一个是user_id, 一个是assign_to_user,

      <br />&#039;user_id&#039;: fields.many2one(&#039;res.users&#039;, &#039;负责人&#039;), <br />&#039;assign_to_user&#039;: fields.many2one(&#039;res.users&#039;, &#039;指派给&#039;),<br />
      


      主管即是user_id,他需要指定工作的接受人assign_to_user, 当他选择好人员,安排好工作后,点击“确定”按钮,则系统自动发送一封email给assign_to_user,现在我不知道如何取得assign_to_user的email,请大家帮忙看一下。
      我可以通过如下代码取得user_id的emal:

      <br />user_obj = self.pool.get(&#039;res.users&#039;)<br />user = user_obj.browse(cr, uid, uid)<br />mail=user.address_id.email<br />
      


      请大家帮忙,我如何取得assign_to_user的mail,谢谢!

      1 Reply Last reply Reply Quote 0
      • Joshua
        Joshua 管理员 last edited by

        你可以这样

        <br />user_obj = self.pool.get(&#039;res.users&#039;)<br />user = user_obj.browse(cr, uid, uid)<br />assign_to_user_email = user.assign_to_user.address_id.email<br />
        
        1 Reply Last reply Reply Quote 0
        • J
          jerry79 last edited by

          非常感谢,不过我试了一下,错误提示如下:
          AttributeError: "Field 'assign_to' does not exist in object 'browse_record(res.users, 1)'"

          1 Reply Last reply Reply Quote 0
          • Joshua
            Joshua 管理员 last edited by

            不好意思,看来是我理解错了

            <br />&#039;user_id&#039;: fields.many2one(&#039;res.users&#039;, &#039;负责人&#039;), <br />&#039;assign_to_user&#039;: fields.many2one(&#039;res.users&#039;, &#039;指派给&#039;),<br />
            



            你的意思是现在有user_id想找出相应的assign_to_user?
            那你就直接search你上面的class搜出user_id = uid 然后读取出assign_to_user

            <br />ids = self.pool.get(&#039;class&#039;).search(cr, uid , [(&#039;user_id&#039;,&#039;=&#039;,uid)])<br />class = self.pool.get(&#039;class&#039;).browse(cr, uid , ids )<br />class.assign_to_user.address_id.email<br />
            
            1 Reply Last reply Reply Quote 0
            • J
              jerry79 last edited by

              谢谢,不过这样也有问题,但是我使用如下的代码实现了:

              <br />def get_user_email(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; for case in self.browse(cr, uid, ids, context=context):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if case.assign_to.user_email:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  email=case.assign_to.user_email<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return email<br />&nbsp; &nbsp; &nbsp; &nbsp; return False<br />
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post