Browse Source

[I18N] survey_template internationalization

12.0
Rémi FRANÇOIS 5 years ago
parent
commit
89246d155c
  1. 2
      survey_template/__manifest__.py
  2. 102
      survey_template/i18n/fr.po
  3. 102
      survey_template/i18n/survey_template.pot
  4. 35
      survey_template/models/survey_survey.py
  5. 25
      survey_template/views/survey_survey.xml

2
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.
""",

102
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."

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

35
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)"), "")

25
survey_template/views/survey_survey.xml

@ -16,11 +16,15 @@
<button name="action_send_survey" position="attributes">
<attribute name="attrs">{'invisible': [('is_template', '=', True)]}</attribute>
</button>
<field name="stage_id" position="before">
<button type="object" nmae="create_survey_from_template" string="Create a survey from this template"
attrs="{'invisible':[('is_template','=',False)]}" class="btn btn-warning" icon="fa-copy"/>
</field>
<field name="stage_id" position="attributes">
<attribute name="attrs">{'invisible': [('is_template', '=', True)]}</attribute>
</field>
<div name="button_box" position="after">
<h2 class="badge-pill badge-warning float-right" attrs="{'invisible': [('is_template', '=', False)]}">Ce sondage est un modèle</h2>
<h2 class="badge-pill badge-warning float-right" attrs="{'invisible': [('is_template', '=', False)]}">This survey is a template</h2>
</div>
</field>
</record>
@ -46,8 +50,11 @@
<field name="inherit_id" ref="survey.survey_kanban"/>
<field name="priority">20</field>
<field name="arch" type="xml">
<field name="title" position="after">
<field name="is_template"/>
</field>
<xpath expr="//div[hasclass('oe_kanban_bottom_left')]" position="inside">
<div t-if="record.is_template.raw_value" class="badge-pill badge-warning">Modèle</div>
<div t-if="record.is_template.raw_value" class="badge-pill badge-warning">Template</div>
</xpath>
</field>
</record>
@ -67,6 +74,8 @@
<field name="active" invisible="1"/>
<field name="is_template" invisible="1"/>
<field name="title"/>
<button type="object" name="create_survey_from_template" title="Create a survey from this template"
attrs="{'invisible':[('is_template','=',False)]}" icon="fa-copy"/>
</tree>
</field>
</record>
@ -88,8 +97,8 @@
<span class="fa fa-ellipsis-v"/>
</a>
<div class="dropdown-menu" role="menu">
<a role="menuitem" type="edit" class="dropdown-item">Modifieer le modèle</a>
<a t-if="widget.deletable" role="menuitem" type="delete" class="dropdown-item">Supprimer ce modèle</a>
<a role="menuitem" type="edit" class="dropdown-item">Modify template</a>
<a t-if="widget.deletable" role="menuitem" type="delete" class="dropdown-item">Delete template</a>
<div role="separator" class="dropdown-divider"/>
<div role="separator" class="dropdown-item-text">Color</div>
<ul class="oe_kanban_colorpicker" data-field="color"/>
@ -100,7 +109,7 @@
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
<div t-if="record.is_template.raw_value" class="badge-pill badge-warning">Modèle</div>
<div t-if="record.is_template.raw_value" class="badge-pill badge-warning">Template</div>
</div>
<div class="oe_kanban_bottom_right">
<field name="activity_ids" widget="kanban_activity"/>
@ -113,7 +122,7 @@
</record>
<record id="survey_survey_template_act_window" model="ir.actions.act_window">
<field name="name">Modèles de sondages</field>
<field name="name">Survey templates</field>
<field name="res_model">survey.survey</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
@ -121,7 +130,7 @@
<field name="context">{'default_is_template':True}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Créez un nouveau modèle de sondage.
Create a new survey template from here
</p>
</field>
</record>
@ -148,7 +157,7 @@
<menuitem
id="survey_survey_template_menu"
name="Modèles"
name="Survey templates"
action="survey_survey_template_act_window"
parent="survey.menu_surveys_configuration"
sequence="0"

Loading…
Cancel
Save