跳至内容
菜单
此问题已终结
2 回复
5031 查看

    @api.model

    def name_search(self, name, args=None, operator='ilike', limit=100):

        args = args or []

        recs = self.browse()

        if name:

            recs = self.search([('bool_field', '=', name)] + args, limit=limit)

        if not recs:

            recs = self.search([('bool_field', operator, name)] + args, limit=limit)

        return recs

    bool_field = fields.Boolean(
      compute="invoicesbool",
        string=bool Field", search=name_search)


TypeError: can only concatenate list (not "bool") to list

形象
丢弃
编写者 最佳答案

Yep, I got the required result:

We can search non stored field like this :

field_name = fields.Boolean(compute="compute_meth", search='_value_search')

@depends('dependent_field')

def compute_meth(self):

# Your compted code

then

@api.multi

def _value_search(self, operator, value):

    recs = self.search([]).filtered(lambda x : x.field_name is True )

    if recs:

               return [('id', 'in', [x.id for x in recs])]

Now you can get it in list mode as well.

形象
丢弃
最佳答案

Great, Above eg works fine for my case. The filters works fine thq

形象
丢弃