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.

30 lines
966 B

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