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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +