Rémi FRANÇOIS
5 years ago
9 changed files with 261 additions and 0 deletions
-
1survey_select_input/__init__.py
-
33survey_select_input/__manifest__.py
-
52survey_select_input/i18n/fr.po
-
52survey_select_input/i18n/survey_select_input.pot
-
2survey_select_input/models/__init__.py
-
27survey_select_input/models/survey_survey.py
-
13survey_select_input/models/survey_user_input.py
-
21survey_select_input/views/survey_survey.xml
-
60survey_select_input/views/survey_user_input.xml
@ -0,0 +1 @@ |
|||
from . import models |
@ -0,0 +1,33 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
{ |
|||
'name': 'Survey answer selection', |
|||
'version': '1.0.0', |
|||
'summary': """ |
|||
This module adds the mossibility to select some of the surveys answers. |
|||
""", |
|||
'description': """ """, |
|||
'author': 'Sudokeys', |
|||
'website': 'http://www.sudokeys.com', |
|||
'license': 'AGPL-3', |
|||
'category': 'Marketing', |
|||
'depends': [ |
|||
'survey', |
|||
], |
|||
'data': [ |
|||
'views/survey_survey.xml', |
|||
'views/survey_user_input.xml', |
|||
], |
|||
'demo': [], |
|||
'auto_install': False, |
|||
'external_dependencies': [], |
|||
'application': False, |
|||
'css': [], |
|||
'images': [], |
|||
'js': [], |
|||
'installable': True, |
|||
'maintainer': 'Sudokeys', |
|||
'pre_init_hook': '', |
|||
'post_init_hook': '', |
|||
'uninstall_hook': '', |
|||
} |
@ -0,0 +1,52 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * survey_select_input |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 12.0+e\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2020-03-23 10:26+0000\n" |
|||
"PO-Revision-Date: 2020-03-23 10:26+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: survey_select_input |
|||
#: code:addons/survey_select_input/models/survey_survey.py:26 |
|||
#, python-format |
|||
msgid " from all ones" |
|||
msgstr " de tous les sondés" |
|||
|
|||
#. module: survey_select_input |
|||
#: code:addons/survey_select_input/models/survey_survey.py:24 |
|||
#, python-format |
|||
msgid " selected" |
|||
msgstr " retenues" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model.fields,field_description:survey_select_input.field_survey_survey__tot_selected_survey |
|||
msgid "Number of selected surveys" |
|||
msgstr "Nombre de réponses retenues" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model.fields,field_description:survey_select_input.field_survey_user_input__selected |
|||
#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_survey_form |
|||
#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_user_input_search |
|||
#: model_terms:ir.ui.view,arch_db:survey_select_input.view_survey_user_input_kanban |
|||
msgid "Selected" |
|||
msgstr "Retenue" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model,name:survey_select_input.model_survey_survey |
|||
msgid "Survey" |
|||
msgstr "Sondage" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model,name:survey_select_input.model_survey_user_input |
|||
msgid "Survey User Input" |
|||
msgstr "Saisie utilisateur du sondage" |
|||
|
@ -0,0 +1,52 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * survey_select_input |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 12.0+e\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2020-03-23 10:27+0000\n" |
|||
"PO-Revision-Date: 2020-03-23 10:27+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: survey_select_input |
|||
#: code:addons/survey_select_input/models/survey_survey.py:26 |
|||
#, python-format |
|||
msgid " from all ones" |
|||
msgstr "" |
|||
|
|||
#. module: survey_select_input |
|||
#: code:addons/survey_select_input/models/survey_survey.py:24 |
|||
#, python-format |
|||
msgid " selected" |
|||
msgstr "" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model.fields,field_description:survey_select_input.field_survey_survey__tot_selected_survey |
|||
msgid "Number of selected surveys" |
|||
msgstr "" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model.fields,field_description:survey_select_input.field_survey_user_input__selected |
|||
#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_survey_form |
|||
#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_user_input_search |
|||
#: model_terms:ir.ui.view,arch_db:survey_select_input.view_survey_user_input_kanban |
|||
msgid "Selected" |
|||
msgstr "" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model,name:survey_select_input.model_survey_survey |
|||
msgid "Survey" |
|||
msgstr "" |
|||
|
|||
#. module: survey_select_input |
|||
#: model:ir.model,name:survey_select_input.model_survey_user_input |
|||
msgid "Survey User Input" |
|||
msgstr "" |
|||
|
@ -0,0 +1,2 @@ |
|||
from . import survey_survey |
|||
from . import survey_user_input |
@ -0,0 +1,27 @@ |
|||
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 |
@ -0,0 +1,13 @@ |
|||
from odoo import models, fields, api |
|||
|
|||
|
|||
class SurveyUserInput(models.Model): |
|||
_inherit = 'survey.user_input' |
|||
|
|||
selected = fields.Boolean(string="Selected", default=False) |
|||
|
|||
@api.multi |
|||
def toggle_selected(self): |
|||
unselect = self.filtered('selected') |
|||
unselect.write({'selected': False}) |
|||
(self - unselect).write({'selected': True}) |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="survey_survey_form" model="ir.ui.view"> |
|||
<field name="name">survey_select_input survey.survey form</field> |
|||
<field name="model">survey.survey</field> |
|||
<field name="inherit_id" ref="survey.survey_form"/> |
|||
<field name="priority">23</field> |
|||
<field name="arch" type="xml"> |
|||
<button name="action_survey_user_input" position="after"> |
|||
<button type="object" name="action_survey_user_input" |
|||
attrs="{'invisible': [('tot_selected_survey','=',0)]}" |
|||
context="{'search_default_selected':1}" |
|||
class="oe_stat_button text-success" icon="fa-pencil-square-o"> |
|||
<field name="tot_selected_survey" string="Selected" widget="statinfo"/> |
|||
</button> |
|||
</button> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,60 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="survey_user_input_form" model="ir.ui.view"> |
|||
<field name="name">survey_select_input survey.user_input form</field> |
|||
<field name="model">survey.user_input</field> |
|||
<field name="inherit_id" ref="survey.survey_user_input_form"/> |
|||
<field name="priority">23</field> |
|||
<field name="arch" type="xml"> |
|||
<div name="button_box" position="inside"> |
|||
<button type="object" name="toggle_selected" class="oe_stat_button" icon="fa-check" |
|||
attrs="{'invisible':['|','|',('test_entry','=',True),('state','!=','done')]}"> |
|||
<field name="selected" widget="boolean_button" |
|||
options="{'terminology': {'string_true': 'Selected', 'string_false': 'Not selected', 'hover_false': 'Select', 'hover_true': 'Unselect'}}"/> |
|||
</button> |
|||
</div> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="survey_user_input_tree" model="ir.ui.view"> |
|||
<field name="name">survey_select_input survey.user_input tree</field> |
|||
<field name="model">survey.user_input</field> |
|||
<field name="inherit_id" ref="survey.survey_user_input_tree"/> |
|||
<field name="priority">23</field> |
|||
<field name="arch" type="xml"> |
|||
<field name="state" position="after"> |
|||
<field name="selected" widget="boolean_toggle" attrs="{'invisible':['|',('test_entry','=',True),('state','!=','done')]}"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_survey_user_input_kanban" model="ir.ui.view"> |
|||
<field name="name">survey_select_input survey.user_input kanban</field> |
|||
<field name="model">survey.user_input</field> |
|||
<field name="inherit_id" ref="survey.view_survey_user_input_kanban"/> |
|||
<field name="priority">23</field> |
|||
<field name="arch" type="xml"> |
|||
<field name="state" position="after"> |
|||
<field name="selected"/> |
|||
</field> |
|||
<xpath expr="//div[hasclass('o_kanban_record_top')]" position="inside"> |
|||
<span t-if="record.selected.raw_value" class="badge-pill badge-success">Selected</span> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="survey_user_input_search" model="ir.ui.view"> |
|||
<field name="name">survey_select_input survey.user_input search</field> |
|||
<field name="model">survey.user_input</field> |
|||
<field name="inherit_id" ref="survey.survey_user_input_search"/> |
|||
<field name="priority">23</field> |
|||
<field name="arch" type="xml"> |
|||
<filter name="new" position="after"> |
|||
<separator/> |
|||
<filter string="Selected" name="selected" domain="[('selected','=', True)]"/> |
|||
</filter> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue