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

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

    怎么知道domain中可以使用那些对象

    Odoo 开发与实施交流
    3
    6
    2257
    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.
    • S
      swisse last edited by

      例如['|','|',('group_ids','in',[g.id for g in user.groups_id]), ('user_id', '=', user.id), '&', ('user_id', '=', False), ('group_ids','=',False),  '|','|', ('company_id','=',False), ('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
      user.id表示一个登陆用户的id,在写domain时,如何知道有哪些对象可用,如何写。例如安装了hr模块,想写一个员工的id,应该怎么写:hr_employee.id  或 hr.employee.id都是错的。

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

        首先要明白domain是什么,domain实际上就是对‘实体对象‘(或者简单理解为数据库表)的记录的过滤规则。

        所以,与你问得正相反,写domain首先要确定作用的对象(实体对象)是什么。在确认对象后你就可以对该对象的对应字段创建过滤规则,即domain.

        而实体对象的名称及其字段的名称是在模块的类定义中的。比如员工对象的名称就是在类属性_name中定义的_name='hr.employee'
        如果你的domain是对hr.emplyee对象的,那么每个员工的id就是:id

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

          楼主可能是想问 domain 单元素中, 第三个 值可用的对象. 比如 例子中的 user 对象...

          他可能想知道倒底还有些嘛对象可以使用...

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

            可以尝试一下 下面几个对象. 看能不能用.

            self, object, obj, pool, time, cr, context, uid, user

            在这几个中挑个你稀饭的... 😛

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

              引用一下 buke 发的内容. 供参考:

              <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;message_ids&#039;: fields.one2many(&#039;mail.message&#039;, &#039;res_id&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; domain=lambda self: [(&#039;model&#039;, &#039;=&#039;, self._name)],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; auto_join=True,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string=&#039;Messages&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; help=&quot;Messages and communication history&quot;),<br />
              



              还要注意  auto_join 参数....

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