diff --git a/survey_template/__manifest__.py b/survey_template/__manifest__.py
index 3d3311b..a7c6f24 100644
--- a/survey_template/__manifest__.py
+++ b/survey_template/__manifest__.py
@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Survey template',
- 'version': '0.1.0',
+ 'version': '1.0.0',
'summary': """
This module adds templating feature on surveys and their own menu item.
""",
diff --git a/survey_template/i18n/fr.po b/survey_template/i18n/fr.po
new file mode 100644
index 0000000..cf310ee
--- /dev/null
+++ b/survey_template/i18n/fr.po
@@ -0,0 +1,102 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * survey_template
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0+e\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-03-23 10:28+0000\n"
+"PO-Revision-Date: 2020-03-23 10:28+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_template
+#: code:addons/survey_template/models/survey_survey.py:16
+#: code:addons/survey_template/models/survey_survey.py:17
+#: code:addons/survey_template/models/survey_survey.py:43
+#: code:addons/survey_template/models/survey_survey.py:45
+#: code:addons/survey_template/models/survey_survey.py:46
+#, python-format
+msgid " (Template)"
+msgstr " (Modèle)"
+
+#. module: survey_template
+#: code:addons/survey_template/models/survey_survey.py:42
+#, python-format
+msgid "(Template)"
+msgstr "(Modèle)"
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Color"
+msgstr "Couleur"
+
+#. module: survey_template
+#: model_terms:ir.actions.act_window,help:survey_template.survey_survey_template_act_window
+msgid "Create a new survey template from here"
+msgstr "Créez un nouveau modèle de sondage."
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_form
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_tree
+msgid "Create a survey from this template"
+msgstr "Créer un sondage depuis ce modèle"
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Delete template"
+msgstr "Supprimer le modèle"
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Dropdown menu"
+msgstr "Menu déroulant"
+
+#. module: survey_template
+#: model:ir.model.fields,field_description:survey_template.field_survey_survey__is_template
+msgid "Is a template"
+msgstr "Est un modèle"
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Modify template"
+msgstr "Modifier le modèle"
+
+#. module: survey_template
+#: model:ir.model,name:survey_template.model_survey_survey
+msgid "Survey"
+msgstr "Sondage"
+
+#. module: survey_template
+#: model:ir.actions.act_window,name:survey_template.survey_survey_template_act_window
+#: model:ir.ui.menu,name:survey_template.survey_survey_template_menu
+msgid "Survey templates"
+msgstr "Modèles de sondages"
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_kanban
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Template"
+msgstr "Modèle"
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_form
+msgid "This survey is a template"
+msgstr "Ce sondage est un modèle"
+
+#. module: survey_template
+#: code:addons/survey_template/models/survey_survey.py:33
+#, python-format
+msgid "You cannot send a template survey, create a new survey from this template and you'll be able to share it."
+msgstr "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."
+
+#. module: survey_template
+#: code:addons/survey_template/models/survey_survey.py:26
+#, python-format
+msgid "You should use the \"Copy\" secondary action to duplicate a non-template survey."
+msgstr "Vous devez utiliser l'action secondaire \"Dupliquer\" pour les sondages qui ne sont pas des modèles."
diff --git a/survey_template/i18n/survey_template.pot b/survey_template/i18n/survey_template.pot
new file mode 100644
index 0000000..6740ea0
--- /dev/null
+++ b/survey_template/i18n/survey_template.pot
@@ -0,0 +1,102 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * survey_template
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0+e\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-03-23 10:29+0000\n"
+"PO-Revision-Date: 2020-03-23 10:29+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_template
+#: code:addons/survey_template/models/survey_survey.py:16
+#: code:addons/survey_template/models/survey_survey.py:17
+#: code:addons/survey_template/models/survey_survey.py:43
+#: code:addons/survey_template/models/survey_survey.py:45
+#: code:addons/survey_template/models/survey_survey.py:46
+#, python-format
+msgid " (Template)"
+msgstr ""
+
+#. module: survey_template
+#: code:addons/survey_template/models/survey_survey.py:42
+#, python-format
+msgid "(Template)"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Color"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.actions.act_window,help:survey_template.survey_survey_template_act_window
+msgid "Create a new survey template from here"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_form
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_tree
+msgid "Create a survey from this template"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Delete template"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Dropdown menu"
+msgstr ""
+
+#. module: survey_template
+#: model:ir.model.fields,field_description:survey_template.field_survey_survey__is_template
+msgid "Is a template"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Modify template"
+msgstr ""
+
+#. module: survey_template
+#: model:ir.model,name:survey_template.model_survey_survey
+msgid "Survey"
+msgstr ""
+
+#. module: survey_template
+#: model:ir.actions.act_window,name:survey_template.survey_survey_template_act_window
+#: model:ir.ui.menu,name:survey_template.survey_survey_template_menu
+msgid "Survey templates"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_kanban
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_template_kanban
+msgid "Template"
+msgstr ""
+
+#. module: survey_template
+#: model_terms:ir.ui.view,arch_db:survey_template.survey_survey_form
+msgid "This survey is a template"
+msgstr ""
+
+#. module: survey_template
+#: code:addons/survey_template/models/survey_survey.py:33
+#, python-format
+msgid "You cannot send a template survey, create a new survey from this template and you'll be able to share it."
+msgstr ""
+
+#. module: survey_template
+#: code:addons/survey_template/models/survey_survey.py:26
+#, python-format
+msgid "You should use the \"Copy\" secondary action to duplicate a non-template survey."
+msgstr ""
diff --git a/survey_template/models/survey_survey.py b/survey_template/models/survey_survey.py
index 5efdd76..3a9280d 100644
--- a/survey_template/models/survey_survey.py
+++ b/survey_template/models/survey_survey.py
@@ -1,17 +1,46 @@
-from odoo import models, fields, api
+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)
+ is_template = fields.Boolean(string="Is a template", default=False, copy=False)
+
+ @api.multi
+ def copy_data(self, default=None):
+ data = super(SurveySurvey, self).copy_data(default)[0]
+ title = isinstance(default, dict) and default.get('title', False) or False
+ if title:
+ data['title'] = title
+ elif _(" (Template)") in data['title']:
+ data['title'] = data['title'].replace(_(" (Template)"), "")
+ return [data]
# ACTIONS
+ @api.multi
+ def create_survey_from_template(self):
+ self.ensure_one()
+ if not self.is_template:
+ raise UserError(_("You should use the \"Copy\" secondary action to duplicate a non-template survey."))
+ return self.copy()
+
@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.")
+ raise UserError(_("You cannot send a template survey, create a new survey from this template and you'll be able to share it."))
return super(SurveySurvey, self).action_send_survey()
+
+ # ONCHANGES
+
+ @api.onchange('is_template')
+ def onchange_is_template(self):
+ if self.title:
+ if self.is_template:
+ if _("(Template)") not in self.title:
+ self.title = self.title.strip() + _(" (Template)")
+ else:
+ if _(" (Template)") in self.title:
+ self.title = self.title.replace(_(" (Template)"), "")
diff --git a/survey_template/views/survey_survey.xml b/survey_template/views/survey_survey.xml
index 406e2c4..c6fceab 100644
--- a/survey_template/views/survey_survey.xml
+++ b/survey_template/views/survey_survey.xml
@@ -16,11 +16,15 @@
+
- Créez un nouveau modèle de sondage. + Create a new survey template from here