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
27 lines
968 B
from odoo import models, fields, api, _
|
|
|
|
|
|
class SurveySurvey(models.Model):
|
|
_inherit = 'survey.survey'
|
|
|
|
tot_selected_survey = fields.Integer("Number of selected surveys", compute="_get_selected_input")
|
|
|
|
@api.depends('user_input_ids', 'user_input_ids.selected')
|
|
def _get_selected_input(self):
|
|
selected_survey = self.env['survey.user_input'].search([
|
|
('survey_id', 'in', self.ids),
|
|
('selected', '=', True)
|
|
])
|
|
for survey in self:
|
|
survey.tot_selected_survey = len(selected_survey.filtered(lambda user_input: user_input.survey_id == survey))
|
|
|
|
# ACTIONS
|
|
|
|
@api.multi
|
|
def action_survey_user_input(self):
|
|
action = super(SurveySurvey, self).action_survey_user_input()
|
|
if self.env.context.get('search_default_selected', False):
|
|
action['display_name'] += _(" selected")
|
|
else:
|
|
action['display_name'] += _(" from all ones")
|
|
return action
|