adapt to ir.message

This commit is contained in:
?ngel ?lvarez 2019-03-30 09:30:51 +01:00
parent dbdc245d78
commit c18754dab2
5 changed files with 24 additions and 16 deletions

View File

@ -7,6 +7,8 @@ from trytond.pool import Pool
from trytond.wizard import Button, StateView, Wizard, StateTransition
from trytond.tools import grouped_slice
import os
from trytond.i18n import gettext
from trytond.exceptions import UserError
__all__ = ['LoadCountryZipsStart', 'LoadCountryZips']
@ -27,13 +29,6 @@ class LoadCountryZips(Wizard):
])
accept = StateTransition()
@classmethod
def __setup__(cls):
super(LoadCountryZips, cls).__setup__()
cls._error_messages.update({
'error': 'CSV Import Error!',
'read_error': 'Error reading file: %s.\nError raised: %s.',
})
def transition_accept(self):
pool = Pool()
@ -48,9 +43,8 @@ class LoadCountryZips(Wizard):
try:
rows = reader(data, delimiter=delimiter, quotechar=quotechar)
except TypeError as e:
self.raise_user_error('error',
error_description='read_error',
error_description_args=('country_zip_es.csv', e))
raise UserError(gettext(
'country_zip_es.error', filename='country_zip_es', error=e))
next(rows)
records = []

View File

@ -1,4 +1,4 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
@ -8,8 +8,8 @@ msgstr "Error importació CSV"
msgctxt "error:load.country.zips:"
msgid ""
"Error reading file: %s.\n"
"Error raised: %s."
"Error reading file: %(filename)s.\n"
"Error raised: %(error)s."
msgstr ""
"Error llegint fitxer: %s.\n"
"Error obtingut: %s."

View File

@ -1,4 +1,4 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
@ -8,8 +8,8 @@ msgstr "Error de importación CSV"
msgctxt "error:load.country.zips:"
msgid ""
"Error reading file: %s.\n"
"Error raised: %s."
"Error reading file: %(filename)s.\n"
"Error raised: %(error)s."
msgstr ""
"Error leyendo fichero: %s.\n"
"Error obtenido: %s."

13
messages.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data group="1">
<record model="ir.message" id="error">
<field name="text">CSV Import Error!</field>
</record>
<record model="ir.message" id="read_error">
<field name="text">Error reading file: %(file_name)s.\nError raised: %(error)s.</field>
</record>
</data>
</tryton>

View File

@ -5,3 +5,4 @@ depends:
party
xml:
country_zip.xml
messages.xml