You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
685 B

  1. # Copyright 2019 Onestein
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class IrFilters(models.Model):
  5. _inherit = 'ir.filters'
  6. facet = fields.Text()
  7. @api.model
  8. def get_filters(self, model, action_id=None):
  9. res = super().get_filters(model, action_id)
  10. ids = map(lambda f: f['id'], res)
  11. # Browse filters that are in res
  12. filters = self.browse(ids)
  13. for i, res_filter in enumerate(res):
  14. # Add the field 'facet' to the result
  15. res[i]['facet'] = filters.filtered(
  16. lambda f: f.id == res_filter['id']
  17. ).facet
  18. return res