Replace unallowed ascii caracters by '-'

Update some error messages
Update translation files and FR translation
Include sepa_export in gen_args
Factorize more code between SDD and SCT
Fix view of payment lines
The modules account_banking_pain_base and account_banking_sepa_* are now fully PEP8 compliant
This commit is contained in:
Alexis de Lattre
2013-12-24 01:01:04 +01:00
committed by Enric Tobella
parent 3908266d28
commit 3de24ccda2
7 changed files with 382 additions and 35 deletions

View File

@@ -62,14 +62,19 @@ class banking_export_pain(orm.AbstractModel):
# Scheme Customer-to-bank guidelines
if gen_args.get('convert_to_ascii'):
value = unidecode(value)
unallowed_ascii_chars = [
'"', '#', '$', '%', '&', '*', ';', '<', '>', '=', '@',
'[', ']', '^', '_', '`', '{', '}', '|', '~', '\\', '!']
for unallowed_ascii_char in unallowed_ascii_chars:
value = value.replace(unallowed_ascii_char, '-')
except:
line = eval_ctx.get('line')
if line:
raise orm.except_orm(
_('Error:'),
_("Cannot compute the '%s' of the Payment Line with Invoice Reference '%s'.")
% (field_name, self.pool['account.invoice'].name_get(
cr, uid, [line.ml_inv_ref.id], context=context)[0][1]))
_("Cannot compute the '%s' of the Payment Line with "
"reference '%s'.")
% (field_name, line.name))
else:
raise orm.except_orm(
_('Error:'),
@@ -77,7 +82,8 @@ class banking_export_pain(orm.AbstractModel):
if not isinstance(value, (str, unicode)):
raise orm.except_orm(
_('Field type error:'),
_("The type of the field '%s' is %s. It should be a string or unicode.")
_("The type of the field '%s' is %s. It should be a string "
"or unicode.")
% (field_name, type(value)))
if not value:
raise orm.except_orm(
@@ -89,22 +95,22 @@ class banking_export_pain(orm.AbstractModel):
return value
def _prepare_export_sepa(
self, cr, uid, sepa_export, total_amount, transactions_count,
xml_string, gen_args, context=None):
self, cr, uid, total_amount, transactions_count, xml_string,
gen_args, context=None):
return {
'batch_booking': sepa_export.batch_booking,
'charge_bearer': sepa_export.charge_bearer,
'batch_booking': gen_args['sepa_export'].batch_booking,
'charge_bearer': gen_args['sepa_export'].charge_bearer,
'total_amount': total_amount,
'nb_transactions': transactions_count,
'file': base64.encodestring(xml_string),
'payment_order_ids': [
(6, 0, [x.id for x in sepa_export.payment_order_ids])
],
'payment_order_ids': [(
6, 0, [x.id for x in gen_args['sepa_export'].payment_order_ids]
)],
}
def _validate_xml(self, cr, uid, xml_string, pain_xsd_file):
def _validate_xml(self, cr, uid, xml_string, gen_args, context=None):
xsd_etree_obj = etree.parse(
tools.file_open(pain_xsd_file))
tools.file_open(gen_args['pain_xsd_file']))
official_pain_schema = etree.XMLSchema(xsd_etree_obj)
try:
@@ -117,19 +123,58 @@ class banking_export_pain(orm.AbstractModel):
logger.warning(e)
raise orm.except_orm(
_('Error:'),
_('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s')
_("The generated XML file is not valid against the official "
"XML Schema Definition. The generated XML file and the "
"full error have been written in the server logs. Here "
"is the error, which may give you an idea on the cause "
"of the problem : %s")
% str(e))
return True
def finalize_sepa_file_creation(
self, cr, uid, ids, xml_root, total_amount, transactions_count,
gen_args, context=None):
xml_string = etree.tostring(
xml_root, pretty_print=True, encoding='UTF-8',
xml_declaration=True)
logger.debug(
"Generated SEPA XML file in format %s below"
% gen_args['pain_flavor'])
logger.debug(xml_string)
self._validate_xml(cr, uid, xml_string, gen_args, context=context)
file_id = gen_args['file_obj'].create(
cr, uid, self._prepare_export_sepa(
cr, uid, total_amount, transactions_count,
xml_string, gen_args, context=context),
context=context)
self.write(
cr, uid, ids, {
'file_id': file_id,
'state': 'finish',
}, context=context)
action = {
'name': 'SEPA File',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': self._name,
'res_id': ids[0],
'target': 'new',
}
return action
def generate_group_header_block(
self, cr, uid, parent_node, sepa_export, gen_args, context=None):
self, cr, uid, parent_node, gen_args, context=None):
group_header_1_0 = etree.SubElement(parent_node, 'GrpHdr')
message_identification_1_1 = etree.SubElement(
group_header_1_0, 'MsgId')
message_identification_1_1.text = self._prepare_field(
cr, uid, 'Message Identification',
'sepa_export.payment_order_ids[0].reference',
{'sepa_export': sepa_export}, 35,
{'sepa_export': gen_args['sepa_export']}, 35,
gen_args=gen_args, context=context)
creation_date_time_1_2 = etree.SubElement(group_header_1_0, 'CreDtTm')
creation_date_time_1_2.text = datetime.strftime(
@@ -138,7 +183,8 @@ class banking_export_pain(orm.AbstractModel):
# batch_booking is in "Group header" with pain.001.001.02
# and in "Payment info" in pain.001.001.03/04
batch_booking = etree.SubElement(group_header_1_0, 'BtchBookg')
batch_booking.text = str(sepa_export.batch_booking).lower()
batch_booking.text = \
str(gen_args['sepa_export'].batch_booking).lower()
nb_of_transactions_1_6 = etree.SubElement(
group_header_1_0, 'NbOfTxs')
control_sum_1_7 = etree.SubElement(group_header_1_0, 'CtrlSum')
@@ -147,12 +193,12 @@ class banking_export_pain(orm.AbstractModel):
grouping = etree.SubElement(group_header_1_0, 'Grpg')
grouping.text = 'GRPD'
self.generate_initiating_party_block(
cr, uid, group_header_1_0, sepa_export, gen_args,
cr, uid, group_header_1_0, gen_args,
context=context)
return group_header_1_0, nb_of_transactions_1_6, control_sum_1_7
def generate_start_payment_info_block(
self, cr, uid, parent_node, sepa_export, payment_info_ident,
self, cr, uid, parent_node, payment_info_ident,
priority, local_instrument, sequence_type, requested_date,
eval_ctx, gen_args, context=None):
payment_info_2_0 = etree.SubElement(parent_node, 'PmtInf')
@@ -171,7 +217,8 @@ class banking_export_pain(orm.AbstractModel):
request_date_tag = 'ReqdExctnDt'
if gen_args.get('pain_flavor') != 'pain.001.001.02':
batch_booking_2_3 = etree.SubElement(payment_info_2_0, 'BtchBookg')
batch_booking_2_3.text = str(sepa_export.batch_booking).lower()
batch_booking_2_3.text = \
str(gen_args['sepa_export'].batch_booking).lower()
# The "SEPA Customer-to-bank
# Implementation guidelines" for SCT and SDD says that control sum
# and nb_of_transactions should be present
@@ -205,24 +252,23 @@ class banking_export_pain(orm.AbstractModel):
requested_date_2_17.text = requested_date
return payment_info_2_0, nb_of_transactions_2_4, control_sum_2_5
def generate_initiating_party_block(
self, cr, uid, parent_node, sepa_export, gen_args,
context=None):
self, cr, uid, parent_node, gen_args, context=None):
my_company_name = self._prepare_field(
cr, uid, 'Company Name',
'sepa_export.payment_order_ids[0].mode.bank_id.partner_id.name',
{'sepa_export': sepa_export}, gen_args.get('name_maxsize'),
gen_args=gen_args, context=context)
{'sepa_export': gen_args['sepa_export']},
gen_args.get('name_maxsize'), gen_args=gen_args, context=context)
initiating_party_1_8 = etree.SubElement(parent_node, 'InitgPty')
initiating_party_name = etree.SubElement(initiating_party_1_8, 'Nm')
initiating_party_name.text = my_company_name
initiating_party_identifier = self.pool['res.company'].\
_get_initiating_party_identifier(
cr, uid, sepa_export.payment_order_ids[0].company_id.id,
cr, uid,
gen_args['sepa_export'].payment_order_ids[0].company_id.id,
context=context)
initiating_party_issuer = \
sepa_export.payment_order_ids[0].company_id.initiating_party_issuer
initiating_party_issuer = gen_args['sepa_export'].\
payment_order_ids[0].company_id.initiating_party_issuer
if initiating_party_identifier and initiating_party_issuer:
iniparty_id = etree.SubElement(initiating_party_1_8, 'Id')
iniparty_org_id = etree.SubElement(iniparty_id, 'OrgId')
@@ -306,7 +352,8 @@ class banking_export_pain(orm.AbstractModel):
if not line.struct_communication_type:
raise orm.except_orm(
_('Error:'),
_("Missing 'Structured Communication Type' on payment line with your reference '%s'.")
_("Missing 'Structured Communication Type' on payment "
"line with reference '%s'.")
% (line.name))
remittance_info_unstructured_2_100 = etree.SubElement(
remittance_info_2_91, 'Strd')

View File

@@ -31,7 +31,8 @@ class res_company(orm.Model):
_columns = {
'initiating_party_issuer': fields.char(
'Initiating Party Issuer', size=35,
help="This will be used as the 'Initiating Party Issuer' in the PAIN files generated by OpenERP."),
help="This will be used as the 'Initiating Party Issuer' in the "
"PAIN files generated by OpenERP."),
}
def _get_initiating_party_identifier(

View File

@@ -0,0 +1,146 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_banking_pain_base
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-23 21:26+0000\n"
"PO-Revision-Date: 2013-12-23 21:26+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: account_banking_pain_base
#: field:res.company,initiating_party_issuer:0
msgid "Initiating Party Issuer"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:122
#, python-format
msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s"
msgstr ""
#. module: account_banking_pain_base
#: field:payment.line,priority:0
msgid "Priority"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_payment_line
msgid "Payment Line"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_payment_mode
msgid "Payment Mode"
msgstr ""
#. module: account_banking_pain_base
#: help:res.company,initiating_party_issuer:0
msgid "This will be used as the 'Initiating Party Issuer' in the PAIN files generated by OpenERP."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:351
#, python-format
msgid "Missing 'Structured Communication Type' on payment line with reference '%s'."
msgstr ""
#. module: account_banking_pain_base
#: selection:payment.line,priority:0
msgid "Normal"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:70
#, python-format
msgid "Cannot compute the '%s' of the Payment Line with reference '%s'."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:77
#, python-format
msgid "Cannot compute the '%s'."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:81
#, python-format
msgid "The type of the field '%s' is %s. It should be a string or unicode."
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:47
#: code:addons/account_banking_pain_base/banking_export_pain.py:69
#: code:addons/account_banking_pain_base/banking_export_pain.py:76
#: code:addons/account_banking_pain_base/banking_export_pain.py:86
#: code:addons/account_banking_pain_base/banking_export_pain.py:121
#: code:addons/account_banking_pain_base/banking_export_pain.py:350
#, python-format
msgid "Error:"
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_company
msgid "Companies"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:47
#, python-format
msgid "This IBAN is not valid : %s"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:80
#, python-format
msgid "Field type error:"
msgstr ""
#. module: account_banking_pain_base
#: field:payment.line,struct_communication_type:0
msgid "Structured Communication Type"
msgstr ""
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:87
#, python-format
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr ""
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_banking_export_pain
msgid "banking.export.pain"
msgstr ""
#. module: account_banking_pain_base
#: help:payment.mode,convert_to_ascii:0
msgid "If active, OpenERP will convert each accented caracter to the corresponding unaccented caracter, so that only ASCII caracters are used in the generated PAIN file."
msgstr ""
#. module: account_banking_pain_base
#: help:payment.line,priority:0
msgid "This field will be used as the 'Instruction Priority' in the generated PAIN file."
msgstr ""
#. module: account_banking_pain_base
#: view:res.company:0
msgid "Payment Initiation"
msgstr ""
#. module: account_banking_pain_base
#: selection:payment.line,priority:0
msgid "High"
msgstr ""
#. module: account_banking_pain_base
#: field:payment.mode,convert_to_ascii:0
msgid "Convert to ASCII"
msgstr ""

View File

@@ -0,0 +1,146 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_banking_pain_base
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-23 21:27+0000\n"
"PO-Revision-Date: 2013-12-23 21:27+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: account_banking_pain_base
#: field:res.company,initiating_party_issuer:0
msgid "Initiating Party Issuer"
msgstr "Initiating Party Issuer"
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:122
#, python-format
msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s"
msgstr "Le fichier XML généré n'est pas valide par rapport à la Définition du Schéma XML officiel. Le fichier XML généré et le message d'erreur complet ont été écrits dans les logs du serveur. Voici l'erreur, qui vous donnera peut-être une idée sur la cause du problème : %s"
#. module: account_banking_pain_base
#: field:payment.line,priority:0
msgid "Priority"
msgstr "Priorité"
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_payment_line
msgid "Payment Line"
msgstr "Ligne de paiement"
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_payment_mode
msgid "Payment Mode"
msgstr "Mode de paiement"
#. module: account_banking_pain_base
#: help:res.company,initiating_party_issuer:0
msgid "This will be used as the 'Initiating Party Issuer' in the PAIN files generated by OpenERP."
msgstr "Ce champ sera le 'Initiating Party Issuer' dans les fichiers PAIN générés par OpenERP."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:351
#, python-format
msgid "Missing 'Structured Communication Type' on payment line with reference '%s'."
msgstr "Le 'Type de communication structuré' n'est pas renseigné sur la ligne de paiement ayant la référence '%s'."
#. module: account_banking_pain_base
#: selection:payment.line,priority:0
msgid "Normal"
msgstr "Normal"
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:70
#, python-format
msgid "Cannot compute the '%s' of the Payment Line with reference '%s'."
msgstr "Impossible de calculer le '%s' de la ligne de paiement ayant la référence '%s'."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:77
#, python-format
msgid "Cannot compute the '%s'."
msgstr "Impossible de calculer le '%s'."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:81
#, python-format
msgid "The type of the field '%s' is %s. It should be a string or unicode."
msgstr "Le type du champ '%s' est %s. Il devrait être de type string ou unicode."
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:47
#: code:addons/account_banking_pain_base/banking_export_pain.py:69
#: code:addons/account_banking_pain_base/banking_export_pain.py:76
#: code:addons/account_banking_pain_base/banking_export_pain.py:86
#: code:addons/account_banking_pain_base/banking_export_pain.py:121
#: code:addons/account_banking_pain_base/banking_export_pain.py:350
#, python-format
msgid "Error:"
msgstr "Erreur :"
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:47
#, python-format
msgid "This IBAN is not valid : %s"
msgstr "Cet IBAN n'est pas valide : %s"
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:80
#, python-format
msgid "Field type error:"
msgstr "Erreur dans le type de champ :"
#. module: account_banking_pain_base
#: field:payment.line,struct_communication_type:0
msgid "Structured Communication Type"
msgstr "Type de communication structurée"
#. module: account_banking_pain_base
#: code:addons/account_banking_pain_base/banking_export_pain.py:87
#, python-format
msgid "The '%s' is empty or 0. It should have a non-null value."
msgstr "Le '%s' est vide ou égal à 0. Il devrait avoir une valeur non-nulle."
#. module: account_banking_pain_base
#: model:ir.model,name:account_banking_pain_base.model_banking_export_pain
msgid "banking.export.pain"
msgstr "banking.export.pain"
#. module: account_banking_pain_base
#: help:payment.mode,convert_to_ascii:0
msgid "If active, OpenERP will convert each accented caracter to the corresponding unaccented caracter, so that only ASCII caracters are used in the generated PAIN file."
msgstr "Si actif, OpenERP convertira chaque caractère accentué en son équivalent non accentué, de telle façon que seuls des caractères ASCII soient utilisés dans le fichier PAIN généré."
#. module: account_banking_pain_base
#: help:payment.line,priority:0
msgid "This field will be used as the 'Instruction Priority' in the generated PAIN file."
msgstr "Ce champ sera le 'Instruction Priority' dans le fichier PAIN généré."
#. module: account_banking_pain_base
#: view:res.company:0
msgid "Payment Initiation"
msgstr "Payment Initiation"
#. module: account_banking_pain_base
#: selection:payment.line,priority:0
msgid "High"
msgstr "Élevé"
#. module: account_banking_pain_base
#: field:payment.mode,convert_to_ascii:0
msgid "Convert to ASCII"
msgstr "Convertir en ASCII"

View File

@@ -34,11 +34,14 @@ class payment_line(orm.Model):
('NORM', 'Normal'),
('HIGH', 'High'),
], 'Priority',
help="This field will be used as the 'Instruction Priority' in the generated PAIN files."),
help="This field will be used as the 'Instruction Priority' in "
"the generated PAIN file."),
# Update size from 64 to 140, because PAIN allows 140 caracters
'communication': fields.char(
'Communication', size=140, required=True,
help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"),
help="Used as the message between ordering customer and current "
"company. Depicts 'What do you want to say to the recipient "
"about this order ?'"),
'struct_communication_type': fields.selection(
_get_struct_communication_types, 'Structured Communication Type'),
}

View File

@@ -14,11 +14,12 @@
<field name="arch" type="xml">
<field name="bank_id" position="after">
<field name="priority"/>
<newline />
</field>
<field name="communication2" position="replace"/>
<field name="state" position="after">
<field name="struct_communication_type" attrs="{'invisible': [('state', '!=', 'structured')], 'required': [('state', '=', 'structured')]}"/>
</field>
<field name="communication2" position="replace"/>
</field>
</record>
@@ -29,11 +30,12 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']/form//field[@name='bank_id']" position="after">
<field name="priority"/>
<newline />
</xpath>
<xpath expr="//field[@name='line_ids']/form//field[@name='communication2']" position="replace"/>
<xpath expr="//field[@name='line_ids']/form//field[@name='state']" position="after">
<field name="struct_communication_type" attrs="{'invisible': [('state', '!=', 'structured')], 'required': [('state', '=', 'structured')]}"/>
</xpath>
<xpath expr="//field[@name='line_ids']/form//field[@name='communication2']" position="replace"/>
</field>
</record>

View File

@@ -29,7 +29,9 @@ class payment_mode(orm.Model):
_columns = {
'convert_to_ascii': fields.boolean(
'Convert to ASCII',
help="If active, OpenERP will convert each accented caracter to the corresponding unaccented caracter, so that only ASCII caracters are used in the generated PAIN file."),
help="If active, OpenERP will convert each accented caracter to "
"the corresponding unaccented caracter, so that only ASCII "
"caracters are used in the generated PAIN file."),
}
_defaults = {