Browse Source

[ADD] survey_input_template_custom

12.0
Rémi FRANÇOIS 4 years ago
parent
commit
57d6182f03
  1. 1
      survey_input_template_custom/__init__.py
  2. 34
      survey_input_template_custom/__manifest__.py
  3. 51
      survey_input_template_custom/i18n/fr.po
  4. 52
      survey_input_template_custom/i18n/survey_input_template_custom.pot
  5. 1
      survey_input_template_custom/models/__init__.py
  6. 10
      survey_input_template_custom/models/survey_survey.py
  7. 15
      survey_input_template_custom/templates/sfinished.xml
  8. 17
      survey_input_template_custom/templates/survey_init.xml
  9. 19
      survey_input_template_custom/views/survey_survey.xml
  10. 1
      survey_link_input_ratio/__init__.py
  11. 32
      survey_link_input_ratio/__manifest__.py
  12. 58
      survey_link_input_ratio/i18n/fr.po
  13. 58
      survey_link_input_ratio/i18n/survey_link_input_ratio.pot
  14. 1
      survey_link_input_ratio/models/__init__.py
  15. 64
      survey_link_input_ratio/models/survey_survey.py
  16. 54
      survey_link_input_ratio/views/survey_survey.xml

1
survey_input_template_custom/__init__.py

@ -0,0 +1 @@
from . import models

34
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': '',
}

51
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 !\"."

52
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 ""

1
survey_input_template_custom/models/__init__.py

@ -0,0 +1 @@
from . import survey_survey

10
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 !\".")

15
survey_input_template_custom/templates/sfinished.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="sfinished" inherit_id="survey.sfinished">
<h1 position="replace">
<t t-if="survey.thank_you_title">
<h1 t-esc="survey.thank_you_title"/>
</t>
<t t-else="">
<h1>Thank you!</h1>
</t>
</h1>
</template>
</odoo>

17
survey_input_template_custom/templates/survey_init.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="survey_init" inherit_id="survey.survey_init">
<a role="button" position="replace">
<a role="button" class="btn btn-primary btn-lg" t-att-href="'/survey/fill/%s/%s' % (slug(survey), token)">
<t t-if="survey.start_btn_label">
<span t-field="survey.start_btn_label"/>
</t>
<t t-else="">
Start Survey
</t>
</a>
</a>
</template>
</odoo>

19
survey_input_template_custom/views/survey_survey.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="survey_survey_form" model="ir.ui.view">
<field name="name">survey_input_template_custom survey.survey form</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_form"/>
<field name="priority">21</field>
<field name="arch" type="xml">
<xpath expr="//notebook/page[last()]" position="inside">
<group col="4">
<field name="start_btn_label"/>
<field name="thank_you_title"/>
</group>
</xpath>
</field>
</record>
</odoo>

1
survey_link_input_ratio/__init__.py

@ -0,0 +1 @@
from . import models

32
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': '',
}

58
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"

58
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 ""

1
survey_link_input_ratio/models/__init__.py

@ -0,0 +1 @@
from . import survey_survey

64
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

54
survey_link_input_ratio/views/survey_survey.xml

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="survey_survey_form" model="ir.ui.view">
<field name="name">survey_sent_input_ratio survey.survey form</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_form"/>
<field name="priority">24</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='tot_comp_survey']/.." position="before">
<button type="object" name="action_survey_user_input"
context="{'search_default_partially_completed':1, 'search_default_completed':0, 'link_only':1}"
attrs="{'invisible':[('tot_sent_survey','=',0)]}" class="oe_stat_button">
<field string="Started" name="sent_start_ratio" widget="percentpie"/>
</button>
<button type="object" name="action_survey_user_input"
context="{'search_default_completed':1, 'link_only':1}"
attrs="{'invisible':[('tot_sent_survey','=',0)]}" class="oe_stat_button">
<field string="Completed" name="sent_comp_ratio" widget="percentpie"/>
</button>
</xpath>
<xpath expr="//div[hasclass('oe_title')]" position="after">
<field name="tot_sent_survey" invisible="1"/>
<field name="tot_sent_start_survey" invisible="1"/>
<field name="tot_sent_comp_survey" invisible="1"/>
</xpath>
</field>
</record>
<!-- <record id="survey_survey_tree" model="ir.ui.view">
<field name="name">OT31 SURVEY survey.survey tree</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_tree"/>
<field name="priority">36</field>
<field name="arch" type="xml">
<field name="title" position="after">
<field name="aa_type"/>
</field>
</field>
</record> -->
<!-- <record id="survey_survey_kanban" model="ir.ui.view">
<field name="name">OT31 SURVEY survey.survey kanban</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_kanban"/>
<field name="priority">36</field>
<field name="arch" type="xml">
<field name="title" position="after">
<field name="aa_type" readonly="1"/>
</field>
</field>
</record> -->
</odoo>
Loading…
Cancel
Save