diff --git a/survey_input_template_custom/__init__.py b/survey_input_template_custom/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_input_template_custom/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_input_template_custom/__manifest__.py b/survey_input_template_custom/__manifest__.py new file mode 100644 index 0000000..b15bfac --- /dev/null +++ b/survey_input_template_custom/__manifest__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Survey input templates custom', + 'version': '1.0.0', + 'summary': """ + This module allows to customize the survey start button label and the \"Thank you\" page title. + """, + 'description': """ """, + 'author': 'Sudokeys', + 'website': 'http://www.sudokeys.com', + 'license': 'AGPL-3', + 'category': 'Marketing', + 'depends': [ + 'survey', + ], + 'data': [ + 'templates/sfinished.xml', + 'templates/survey_init.xml', + 'views/survey_survey.xml', + ], + 'demo': [], + 'auto_install': False, + 'external_dependencies': [], + 'application': False, + 'css': [], + 'images': [], + 'js': [], + 'installable': True, + 'maintainer': 'Sudokeys', + 'pre_init_hook': '', + 'post_init_hook': '', + 'uninstall_hook': '', +} diff --git a/survey_input_template_custom/i18n/fr.po b/survey_input_template_custom/i18n/fr.po new file mode 100644 index 0000000..3156ced --- /dev/null +++ b/survey_input_template_custom/i18n/fr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_input_template_custom +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-25 11:41+0000\n" +"PO-Revision-Date: 2020-03-25 11:41+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_input_template_custom +#: model_terms:ir.ui.view,arch_db:survey_input_template_custom.survey_init +msgid "Start Survey" +msgstr "Commencer le sondage" + +#. module: survey_input_template_custom +#: model:ir.model.fields,field_description:survey_input_template_custom.field_survey_survey__start_btn_label +msgid "Start button label" +msgstr "Label du bouton" + +#. module: survey_input_template_custom +#: model:ir.model,name:survey_input_template_custom.model_survey_survey +msgid "Survey" +msgstr "Sondage" + +#. module: survey_input_template_custom +#: model:ir.model.fields,field_description:survey_input_template_custom.field_survey_survey__thank_you_title +msgid "Thank you page title" +msgstr "Titre de la page de fin" + +#. module: survey_input_template_custom +#: model_terms:ir.ui.view,arch_db:survey_input_template_custom.sfinished +msgid "Thank you!" +msgstr "Merci !" + +#. module: survey_input_template_custom +#: model:ir.model.fields,help:survey_input_template_custom.field_survey_survey__start_btn_label +msgid "This label will be used in the survey start button. If empty, the label will be \"Start survey\"." +msgstr "Ce label sera utilisé dans le bouton au début du sondage. Si ce champ est vide, le label sera \"Commencer le sondage\"." + +#. module: survey_input_template_custom +#: model:ir.model.fields,help:survey_input_template_custom.field_survey_survey__thank_you_title +msgid "This title will be used in the survey \"Thank you\" page. If empty, the label will be \"Thank you !\"." +msgstr "Ce titre sera utilisé dans la page de fin de la réponse d'un sondé. Si ce champ est vide, le titre sera \"Merci !\"." diff --git a/survey_input_template_custom/i18n/survey_input_template_custom.pot b/survey_input_template_custom/i18n/survey_input_template_custom.pot new file mode 100644 index 0000000..1b24765 --- /dev/null +++ b/survey_input_template_custom/i18n/survey_input_template_custom.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_input_template_custom +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-25 11:42+0000\n" +"PO-Revision-Date: 2020-03-25 11:42+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_input_template_custom +#: model_terms:ir.ui.view,arch_db:survey_input_template_custom.survey_init +msgid "Start Survey" +msgstr "" + +#. module: survey_input_template_custom +#: model:ir.model.fields,field_description:survey_input_template_custom.field_survey_survey__start_btn_label +msgid "Start button label" +msgstr "" + +#. module: survey_input_template_custom +#: model:ir.model,name:survey_input_template_custom.model_survey_survey +msgid "Survey" +msgstr "" + +#. module: survey_input_template_custom +#: model:ir.model.fields,field_description:survey_input_template_custom.field_survey_survey__thank_you_title +msgid "Thank you page title" +msgstr "" + +#. module: survey_input_template_custom +#: model_terms:ir.ui.view,arch_db:survey_input_template_custom.sfinished +msgid "Thank you!" +msgstr "" + +#. module: survey_input_template_custom +#: model:ir.model.fields,help:survey_input_template_custom.field_survey_survey__start_btn_label +msgid "This label will be used in the survey start button. If empty, the label will be \"Start survey\"." +msgstr "" + +#. module: survey_input_template_custom +#: model:ir.model.fields,help:survey_input_template_custom.field_survey_survey__thank_you_title +msgid "This title will be used in the survey \"Thank you\" page. If empty, the label will be \"Thank you !\"." +msgstr "" + diff --git a/survey_input_template_custom/models/__init__.py b/survey_input_template_custom/models/__init__.py new file mode 100644 index 0000000..38d56b9 --- /dev/null +++ b/survey_input_template_custom/models/__init__.py @@ -0,0 +1 @@ +from . import survey_survey diff --git a/survey_input_template_custom/models/survey_survey.py b/survey_input_template_custom/models/survey_survey.py new file mode 100644 index 0000000..54d8589 --- /dev/null +++ b/survey_input_template_custom/models/survey_survey.py @@ -0,0 +1,10 @@ +from odoo import models, fields + + +class SurveySurvey(models.Model): + _inherit = 'survey.survey' + + start_btn_label = fields.Char(string="Start button label", + help="This label will be used in the survey start button. If empty, the label will be \"Start survey\".") + thank_you_title = fields.Char(string="Thank you page title", + help="This title will be used in the survey \"Thank you\" page. If empty, the label will be \"Thank you !\".") diff --git a/survey_input_template_custom/templates/sfinished.xml b/survey_input_template_custom/templates/sfinished.xml new file mode 100644 index 0000000..739e921 --- /dev/null +++ b/survey_input_template_custom/templates/sfinished.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/survey_input_template_custom/templates/survey_init.xml b/survey_input_template_custom/templates/survey_init.xml new file mode 100644 index 0000000..bbc4b0c --- /dev/null +++ b/survey_input_template_custom/templates/survey_init.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/survey_input_template_custom/views/survey_survey.xml b/survey_input_template_custom/views/survey_survey.xml new file mode 100644 index 0000000..fce5293 --- /dev/null +++ b/survey_input_template_custom/views/survey_survey.xml @@ -0,0 +1,19 @@ + + + + + survey_input_template_custom survey.survey form + survey.survey + + 21 + + + + + + + + + + + diff --git a/survey_link_input_ratio/__init__.py b/survey_link_input_ratio/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_link_input_ratio/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_link_input_ratio/__manifest__.py b/survey_link_input_ratio/__manifest__.py new file mode 100644 index 0000000..2c1be54 --- /dev/null +++ b/survey_link_input_ratio/__manifest__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Survey sent answer ratio', + 'version': '1.0.0', + 'summary': """ + This module displays percent pies statistics on sent inputs in survey form stat-buttons. + """, + 'description': """ """, + 'author': 'Sudokeys', + 'website': 'http://www.sudokeys.com', + 'license': 'AGPL-3', + 'category': 'Marketing', + 'depends': [ + 'survey', + ], + 'data': [ + 'views/survey_survey.xml', + ], + 'demo': [], + 'auto_install': False, + 'external_dependencies': [], + 'application': False, + 'css': [], + 'images': [], + 'js': [], + 'installable': True, + 'maintainer': 'Sudokeys', + 'pre_init_hook': '', + 'post_init_hook': '', + 'uninstall_hook': '', +} diff --git a/survey_link_input_ratio/i18n/fr.po b/survey_link_input_ratio/i18n/fr.po new file mode 100644 index 0000000..1b3307d --- /dev/null +++ b/survey_link_input_ratio/i18n/fr.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_link_input_ratio +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-25 11:14+0000\n" +"PO-Revision-Date: 2020-03-25 11:14+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_link_input_ratio +#: code:addons/survey_link_input_ratio/models/survey_survey.py:55 +#, python-format +msgid " (from private links)" +msgstr " (invitations privées)" + +#. module: survey_link_input_ratio +#: model_terms:ir.ui.view,arch_db:survey_link_input_ratio.survey_survey_form +msgid "Completed" +msgstr "Répondu" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__tot_sent_comp_survey +msgid "Completed sent input count" +msgstr "Réponses privées terminées" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__sent_comp_ratio +msgid "Completed sent input ratio" +msgstr "Ratio de réponses privées terminées" + +#. module: survey_link_input_ratio +#: model_terms:ir.ui.view,arch_db:survey_link_input_ratio.survey_survey_form +msgid "Started" +msgstr "En cours" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__tot_sent_start_survey +msgid "Started sent input count" +msgstr "Réponses privées en cours" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__sent_start_ratio +msgid "Started sent input ratio" +msgstr "Ratio de réponses privées en cours" + +#. module: survey_link_input_ratio +#: model:ir.model,name:survey_link_input_ratio.model_survey_survey +msgid "Survey" +msgstr "Sondage" + diff --git a/survey_link_input_ratio/i18n/survey_link_input_ratio.pot b/survey_link_input_ratio/i18n/survey_link_input_ratio.pot new file mode 100644 index 0000000..1174ed0 --- /dev/null +++ b/survey_link_input_ratio/i18n/survey_link_input_ratio.pot @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_link_input_ratio +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-25 11:17+0000\n" +"PO-Revision-Date: 2020-03-25 11:17+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_link_input_ratio +#: code:addons/survey_link_input_ratio/models/survey_survey.py:55 +#, python-format +msgid " (from private links)" +msgstr "" + +#. module: survey_link_input_ratio +#: model_terms:ir.ui.view,arch_db:survey_link_input_ratio.survey_survey_form +msgid "Completed" +msgstr "" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__tot_sent_comp_survey +msgid "Completed sent input count" +msgstr "" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__sent_comp_ratio +msgid "Completed sent input ratio" +msgstr "" + +#. module: survey_link_input_ratio +#: model_terms:ir.ui.view,arch_db:survey_link_input_ratio.survey_survey_form +msgid "Started" +msgstr "" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__tot_sent_start_survey +msgid "Started sent input count" +msgstr "" + +#. module: survey_link_input_ratio +#: model:ir.model.fields,field_description:survey_link_input_ratio.field_survey_survey__sent_start_ratio +msgid "Started sent input ratio" +msgstr "" + +#. module: survey_link_input_ratio +#: model:ir.model,name:survey_link_input_ratio.model_survey_survey +msgid "Survey" +msgstr "" + diff --git a/survey_link_input_ratio/models/__init__.py b/survey_link_input_ratio/models/__init__.py new file mode 100644 index 0000000..38d56b9 --- /dev/null +++ b/survey_link_input_ratio/models/__init__.py @@ -0,0 +1 @@ +from . import survey_survey diff --git a/survey_link_input_ratio/models/survey_survey.py b/survey_link_input_ratio/models/survey_survey.py new file mode 100644 index 0000000..24a52dc --- /dev/null +++ b/survey_link_input_ratio/models/survey_survey.py @@ -0,0 +1,64 @@ +from odoo import models, fields, api, _ +from odoo.osv.expression import normalize_domain, AND + + +class SurveySurvey(models.Model): + _inherit = 'survey.survey' + + tot_sent_start_survey = fields.Integer("Started sent input count", compute="_count_sent_input") + tot_sent_comp_survey = fields.Integer("Completed sent input count", compute="_count_sent_input") + sent_start_ratio = fields.Integer(string="Started sent input ratio", compute="_get_sent_start_ratio") + sent_comp_ratio = fields.Integer(string="Completed sent input ratio", compute="_get_sent_comp_ratio") + + # COMPUTES + + @api.multi + def _count_sent_input(self): + UserInput = self.env['survey.user_input'] + sent_start_survey = UserInput.search([('survey_id', 'in', self.ids), ('type', '=', 'link'), ('state', '=', 'skip'), ('state', '=', 'done')]) + sent_comp_survey = UserInput.search([('survey_id', 'in', self.ids), ('type', '=', 'link'), ('state', '=', 'done')]) + for survey in self: + survey.tot_sent_start_survey = len(sent_start_survey.filtered(lambda user_input: user_input.survey_id == survey)) + survey.tot_sent_comp_survey = len(sent_comp_survey.filtered(lambda user_input: user_input.survey_id == survey)) + + @api.depends('tot_sent_start_survey', 'tot_sent_survey') + def _get_sent_start_ratio(self): + for survey in self: + if survey.tot_sent_survey == 0: + survey.sent_start_ratio = 0 + else: + survey.sent_start_ratio = int(round(100 * (survey.tot_sent_start_survey) / survey.tot_sent_survey, 0)) + + @api.depends('tot_sent_comp_survey', 'tot_sent_survey') + def _get_sent_comp_ratio(self): + for survey in self: + if survey.tot_sent_survey == 0: + survey.sent_comp_ratio = 0 + else: + survey.sent_comp_ratio = int(round(100 * survey.tot_sent_comp_survey / survey.tot_sent_survey, 0)) + + # ACTIONS + + @api.multi + def action_survey_user_input(self): + ctx = dict(self.env.context) + search_completed = ctx.get('search_default_completed', None) + action = super(SurveySurvey, self).action_survey_user_input() + if ctx.get('link_only', False): + domain = action.get('domain') or [] + if isinstance(domain, str): + domain = eval(domain) + if len(domain) > 1: + action['domain'] = AND([[('type', '=', 'link')], normalize_domain(domain)]) + else: + action['domain'] = [('type', '=', 'link')] + action['display_name'] += _(" (from private links)") + if search_completed is not None: + act_ctx = action.get('context') or {} + if isinstance(act_ctx, str): + act_ctx = eval(act_ctx) + if 'search_default_completed' in act_ctx: + if bool(act_ctx['search_default_completed']) is not bool(search_completed): + act_ctx['search_default_completed'] = int(bool(search_completed)) + action['context'] = act_ctx + return action diff --git a/survey_link_input_ratio/views/survey_survey.xml b/survey_link_input_ratio/views/survey_survey.xml new file mode 100644 index 0000000..183ccfb --- /dev/null +++ b/survey_link_input_ratio/views/survey_survey.xml @@ -0,0 +1,54 @@ + + + + + survey_sent_input_ratio survey.survey form + survey.survey + + 24 + + + + + + + + + + + + + + + + + +