Odoo modules related to surveys
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.

27 lines
968 B

  1. from odoo import models, fields, api, _
  2. class SurveySurvey(models.Model):
  3. _inherit = 'survey.survey'
  4. tot_selected_survey = fields.Integer("Number of selected surveys", compute="_get_selected_input")
  5. @api.depends('user_input_ids', 'user_input_ids.selected')
  6. def _get_selected_input(self):
  7. selected_survey = self.env['survey.user_input'].search([
  8. ('survey_id', 'in', self.ids),
  9. ('selected', '=', True)
  10. ])
  11. for survey in self:
  12. survey.tot_selected_survey = len(selected_survey.filtered(lambda user_input: user_input.survey_id == survey))
  13. # ACTIONS
  14. @api.multi
  15. def action_survey_user_input(self):
  16. action = super(SurveySurvey, self).action_survey_user_input()
  17. if self.env.context.get('search_default_selected', False):
  18. action['display_name'] += _(" selected")
  19. else:
  20. action['display_name'] += _(" from all ones")
  21. return action