diff --git a/electronic_mail_wizard.py b/electronic_mail_wizard.py index 8ff48d8..2f52989 100644 --- a/electronic_mail_wizard.py +++ b/electronic_mail_wizard.py @@ -10,6 +10,8 @@ from trytond.pool import Pool from trytond.pyson import Eval from trytond.tools import grouped_slice from trytond.transaction import Transaction +from trytond.exceptions import UserError +from trytond.i18n import gettext from trytond.wizard import Wizard, StateTransition, StateView, Button __all__ = ['TemplateEmailStart', 'TemplateEmailResult', @@ -78,14 +80,6 @@ class GenerateTemplateEmail(Wizard): ]) send = StateTransition() - @classmethod - def __setup__(cls): - super(GenerateTemplateEmail, cls).__setup__() - cls._error_messages.update({ - 'template_deleted': ( - 'This template has been deactivated or deleted.'), - }) - def default_start(self, fields): default = self.render_fields(self.__name__) return default @@ -107,8 +101,10 @@ class GenerateTemplateEmail(Wizard): active_ids = context.get('active_ids') action_id = context.get('action_id', None) wizard = Wizard(action_id) - template = (wizard.template[0] if wizard.template - else self.raise_user_error('template_deleted')) + if not wizard.template: + raise UserError(gettext( + 'electronic_mail_wizard.msg_template_deleted')) + template = wizard.template[0] total = len(active_ids) record = pool.get(template.model.model)(active_ids[0]) diff --git a/locale/ca.po b/locale/ca.po index faad59a..b591c31 100644 --- a/locale/ca.po +++ b/locale/ca.po @@ -2,7 +2,7 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "error:electronic_mail_wizard.templateemail:" +msgctxt "model:ir.message,text:msg_template_deleted" msgid "This template has been deactivated or deleted." msgstr "Aquesta plantilla s'ha desactivat o eliminat." diff --git a/locale/es.po b/locale/es.po index 753a8ce..4570d56 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2,7 +2,7 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "error:electronic_mail_wizard.templateemail:" +msgctxt "model:ir.message,text:msg_template_deleted" msgid "This template has been deactivated or deleted." msgstr "Esta plantilla se ha desactivado o eliminado." diff --git a/message.xml b/message.xml new file mode 100644 index 0000000..e4451fa --- /dev/null +++ b/message.xml @@ -0,0 +1,10 @@ + + + + + + This template has been deactivated or deleted. + + + \ No newline at end of file diff --git a/tryton.cfg b/tryton.cfg index 0e29433..86c1c1d 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -4,6 +4,8 @@ depends: ir res electronic_mail_template + xml: electronic_mail_wizard.xml template.xml + message.xml \ No newline at end of file