تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5020 أدوات العرض

    @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

الصورة الرمزية
إهمال