Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
5025 Zobrazení

    @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

Avatar
Zrušit
Autor Nejlepší odpověď

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.

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit