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. 多对多筛选

多对多筛选

Scheduled Pinned Locked Moved Odoo 开发与实施交流
8 Posts 3 Posters 4.5k 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.
  • 茹 Offline
    茹 Offline
    茹小红
    wrote on last edited by
    #1

    [图片],一号字段时多对多,关联res.users模型,2号字段关联另一个模型。[图片],这是2号关联的模型,
    1号字段取2号的engineers的值,怎么在1号字段进行筛选啊

    1 Reply Last reply
    0
    • 茹 Offline
      茹 Offline
      茹小红
      wrote on last edited by
      #2

      0_1543826541384_7bef4bcd-b02a-4f6e-b70e-ee3c5ef052dd-image.png
      0_1543826525392_aec8698c-6431-406a-b156-4722bd3f5191-image.png

      1 Reply Last reply
      0
      • D Offline
        D Offline
        digitalsatori
        管理员
        wrote on last edited by
        #3

        把assign to的字段设置成related字段关联到discipline.engineer就可以了,比如:

        assign_to = fields.Many2many(related='discipline.engineer',  readonly=True)
        

        【上海先安科技】(tony AT openerp.cn)

        茹 2 Replies Last reply
        0
        • D digitalsatori

          把assign to的字段设置成related字段关联到discipline.engineer就可以了,比如:

          assign_to = fields.Many2many(related='discipline.engineer',  readonly=True)
          
          茹 Offline
          茹 Offline
          茹小红
          wrote on last edited by
          #4

          @digitalsatori 非常感谢您的回复,需求是不能用 related ,只能选2号中的 engineer 的值,有方法吗

          D 1 Reply Last reply
          0
          • 茹 茹小红

            @digitalsatori 非常感谢您的回复,需求是不能用 related ,只能选2号中的 engineer 的值,有方法吗

            D Offline
            D Offline
            digitalsatori
            管理员
            wrote on last edited by
            #5

            @茹小红

            可以对Disciplane字段写 onchange 方法,然后该方法返回一个"Assigned to"字段的domain

            【上海先安科技】(tony AT openerp.cn)

            1 Reply Last reply
            0
            • D digitalsatori

              把assign to的字段设置成related字段关联到discipline.engineer就可以了,比如:

              assign_to = fields.Many2many(related='discipline.engineer',  readonly=True)
              
              茹 Offline
              茹 Offline
              茹小红
              wrote on last edited by
              #6

              @digitalsatori
              1号 assign_to = Manyd2many('res.users', domain="[('id', 'in', discipline_id.engineer_ids)]")
              2号 engineer_ids = fields.Many2many('res.users', string='Engineers')
              就会报这个错
              476ae5f8-3188-41f7-9c7e-61318c5d493f-image.png

              1 Reply Last reply
              0
              • D Offline
                D Offline
                digitalsatori
                管理员
                wrote on last edited by digitalsatori
                #7

                供你参考:

                            @api.onchange('discipline')
                            def _onchange_discipline(self):
                            return {
                                'domain': {'assignedTo': [('id', 'in', self.discipline.engineers.id)]},
                            }

                【上海先安科技】(tony AT openerp.cn)

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kowky
                  wrote on last edited by
                  #8

                  @digitalsatori 在 多对多筛选 中说:

                  assign_to = fields.Many2many(related='discipline.engineer', readonly=True)

                  个人感觉可以参考系统里面的客户 或者供应商的地址城市 的字段吧

                  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