Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 开发与实施交流
  4. many2one字段的下拉列表中过滤数据?

many2one字段的下拉列表中过滤数据?

Scheduled Pinned Locked Moved Odoo 开发与实施交流
3 Posts 2 Posters 2.3k Views 2 Watching
  • 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.
  • W Offline
    W Offline
    wangss
    wrote on last edited by
    #1

    一般many2one过滤数据直接用domain="[(...,op,...)]",那如何设置能使many2one('hr_employee',...)字段的下拉列表中显示的员工都是指定group内的?如想列出所有在某一审批权限组内的员工?

    H 1 Reply Last reply
    0
    • W wangss

      一般many2one过滤数据直接用domain="[(...,op,...)]",那如何设置能使many2one('hr_employee',...)字段的下拉列表中显示的员工都是指定group内的?如想列出所有在某一审批权限组内的员工?

      H Offline
      H Offline
      hui
      wrote on last edited by digitalsatori
      #2

      @wangss
      domain写成一个方法,如下:

      @api.model
      def _get_users(self):
          user_ids = self.env.ref('sps_base.group_duser').mapped('users')
          return [('id', 'in', [x.id for x in user_ids])]
      owner = fields.Many2one('res.users', string='Owner', domain=_get_users)
      
      1 Reply Last reply
      1
      • W Offline
        W Offline
        wangss
        wrote on last edited by
        #3

        谢谢👍

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Tags
        • Popular
        • Users
        • Groups