Review: Needs Fixing
Can you please improve a bit readability of lines like these ones?
data_of_file = '<?xml version="1.0"?>\n<VATConsignment
xmlns="http://www.minfin.fgov.be/VATConsignment"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
VATDeclarationsNbr="'+str(data['vat_declarations_nbr'])+'">'
data_of_file +='\n\t<Representative> \n\t\t<RepresentativeID
identificationType="'+type.upper()+'" issuedBy="'+issued_by+'"
otherQlf="'+other+'">'+str(vat_no)+'</RepresentativeID>
\n\t\t<Name>'+obj_company.name+'</Name> \n\t\t<Street>'+address+'</Street>
\n\t\t<PostCode>'+post_code+'</PostCode> \n\t\t<City>'+city+'</City>
\n\t\t<CountryCode>'+country_code+'</CountryCode>
\n\t\t<EmailAddress>'+email+'</EmailAddress> \n\t\t<Phone>'+phone+'</Phone>
\n\t</Representative>'
data_of_file +='\n\t<RepresentativeReference></RepresentativeReference>'
Use multiline strings and % operators, something like:
data_of_file = """
<?xml version="1.0"?>
<VATConsignment xmlns="http://www.minfin.fgov.be/VATConsignment"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VATDeclarationsNbr="%s">
<Representative>
<RepresentativeID identificationType="%s" issuedBy="%s"
otherQlf="%s">%s</RepresentativeID>
<Name>%s</Name>
<Street>%s</Street>
<PostCode>%s</PostCode>
<City>%s</City>
<CountryCode>%s</CountryCode>
<EmailAddress>%s</EmailAddress>
<Phone>%s</Phone>
</Representative>
""" % (data['vat_declarations_nbr'], type.upper(), issued_by, other, vat_no,
obj_company.name, address, post_code, city, country_code, email, phone)
You could even use named parameters "%(stuff)s" in the string, and pass values
in a dictionary. This would definitively make it readable.
Thanks,
Raphael
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-l10n_be-periodical-vat-declaration-bde/+merge/88683
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-l10n_be-periodical-vat-declaration-bde.
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp