From 097c10e6628f729405607cbea6b2e75d37ce1af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20FRAN=C3=87OIS?= Date: Fri, 20 Mar 2020 13:39:39 +0100 Subject: [PATCH] [ADD] survey_template module --- survey_template/__init__.py | 1 + survey_template/__manifest__.py | 32 +++++ survey_template/models/__init__.py | 1 + survey_template/models/survey_survey.py | 17 +++ survey_template/views/survey_survey.xml | 173 ++++++++++++++++++++++++ 5 files changed, 224 insertions(+) create mode 100644 survey_template/__init__.py create mode 100644 survey_template/__manifest__.py create mode 100644 survey_template/models/__init__.py create mode 100644 survey_template/models/survey_survey.py create mode 100644 survey_template/views/survey_survey.xml diff --git a/survey_template/__init__.py b/survey_template/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_template/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_template/__manifest__.py b/survey_template/__manifest__.py new file mode 100644 index 0000000..3d3311b --- /dev/null +++ b/survey_template/__manifest__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Survey template', + 'version': '0.1.0', + 'summary': """ + This module adds templating feature on surveys and their own menu item. + """, + '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_template/models/__init__.py b/survey_template/models/__init__.py new file mode 100644 index 0000000..38d56b9 --- /dev/null +++ b/survey_template/models/__init__.py @@ -0,0 +1 @@ +from . import survey_survey diff --git a/survey_template/models/survey_survey.py b/survey_template/models/survey_survey.py new file mode 100644 index 0000000..5efdd76 --- /dev/null +++ b/survey_template/models/survey_survey.py @@ -0,0 +1,17 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError + + +class SurveySurvey(models.Model): + _inherit = 'survey.survey' + + is_template = fields.Boolean(string="Est un modèle", default=False, copy=False) + + # ACTIONS + + @api.multi + def action_send_survey(self): + self.ensure_one() + if self.is_template: + raise UserError("Vous ne pouvez pas partager un modèle de sondage, créez un nouveau sondage à partir de ce modèle et vous pourrez le partager.") + return super(SurveySurvey, self).action_send_survey() diff --git a/survey_template/views/survey_survey.xml b/survey_template/views/survey_survey.xml new file mode 100644 index 0000000..406e2c4 --- /dev/null +++ b/survey_template/views/survey_survey.xml @@ -0,0 +1,173 @@ + + + + + + + survey_template survey.survey form + survey.survey + + 20 + + + + + + + + {'invisible': [('is_template', '=', True)]} + +
+

Ce sondage est un modèle

+
+
+
+ + + survey_template survey.survey tree + survey.survey + + 20 + + + is_template + + + + + + + + + survey_template survey.survey kanban + survey.survey + + 20 + + +
Modèle
+
+
+
+ + + [('is_template','=',False)] + + + + + + survey_template survey.survey template tree + survey.survey + 20 + + + + + + + + + + + survey_template survey.survey template kanban + survey.survey + 20 + + + + + + + +
+ + + + + + + + Modèles de sondages + survey.survey + form + kanban,tree,form + [('is_template','=',True)] + {'default_is_template':True} + +

+ Créez un nouveau modèle de sondage. +

+
+
+ + + + kanban + + + + + + + tree + + + + + + + + + + + + + + + + + + + + + + + + + + + + +