Skip to content
Permalink
Browse files

[ADD] l10n_be(_edi): add import/export XML invoices in E-FFF format

  • Loading branch information...
Laurent Smet
Laurent Smet committed Apr 18, 2018
1 parent 064d1b8 commit 4c4cb42701f2b83dd14a32c8e8d62e31d002c11f
Showing with 49,677 additions and 0 deletions.
  1. +2 −0 addons/l10n_be/__init__.py
  2. +1 −0 addons/l10n_be/__manifest__.py
  3. +3 −0 addons/l10n_be/models/__init__.py
  4. +9 −0 addons/l10n_be/models/account_config_settings.py
  5. +23 −0 addons/l10n_be/views/res_config_settings_views.xml
  6. +4 −0 addons/l10n_be_edi/__init__.py
  7. +20 −0 addons/l10n_be_edi/__manifest__.py
  8. +204 −0 addons/l10n_be_edi/data/ubl_invoice_templates.xml
  9. +731 −0 addons/l10n_be_edi/data/xsd/2.1/common/CCTS_CCT_SchemaModule-2.1.xsd
  10. +39,799 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-CommonAggregateComponents-2.1.xsd
  11. +5,389 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-CommonBasicComponents-2.1.xsd
  12. +223 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-CommonExtensionComponents-2.1.xsd
  13. +101 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-CommonSignatureComponents-2.1.xsd
  14. +63 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-CoreComponentParameters-2.1.xsd
  15. +89 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-ExtensionContentDataType-2.1.xsd
  16. +69 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-QualifiedDataTypes-2.1.xsd
  17. +138 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-SignatureAggregateComponents-2.1.xsd
  18. +78 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-SignatureBasicComponents-2.1.xsd
  19. +553 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-UnqualifiedDataTypes-2.1.xsd
  20. +476 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-XAdESv132-2.1.xsd
  21. +25 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-XAdESv141-2.1.xsd
  22. +330 −0 addons/l10n_be_edi/data/xsd/2.1/common/UBL-xmldsig-core-schema-2.1.xsd
  23. +1,002 −0 addons/l10n_be_edi/data/xsd/2.1/maindoc/UBL-Invoice-2.1.xsd
  24. +6 −0 addons/l10n_be_edi/models/__init__.py
  25. +92 −0 addons/l10n_be_edi/models/account_invoice.py
  26. +157 −0 addons/l10n_be_edi/models/import_invoice_xml_wizard.py
  27. +17 −0 addons/l10n_be_edi/models/ir_actions_report.py
  28. +23 −0 addons/l10n_be_edi/models/mail_compose_message.py
  29. +3 −0 addons/l10n_be_edi/tests/__init__.py
  30. +47 −0 addons/l10n_be_edi/tests/test_ubl.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models

from odoo import api, SUPERUSER_ID

def load_translations(cr, registry):
@@ -53,6 +53,7 @@
'data/account_reconcile_model_template.xml',
'data/account_chart_template_configure_data.xml',
'data/menuitem_data.xml',
'views/res_config_settings_views.xml',
],
'demo': [
'demo/l10n_be_demo.xml',
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*

from . import account_config_settings
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-

from odoo import fields, models, _


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

module_l10n_be_edi = fields.Boolean(string='E-Invoicing (Belgium)')
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form_inherit_l10n_be" model="ir.ui.view">
<field name="name">res.config.settings.form.inherit.l10n.be</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='invoicing_settings']" position="inside">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_l10n_be_edi"/>
</div>
<div class="o_setting_right_pane">
<label string="E-Invoicing (Belgium)"/>
<div class="text-muted">
Generate invoices in XML format
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
{
'name': 'Belgium - E-Invoicing (UBL 2.0, e-fff)',
'version': '0.1',
'category': 'Hidden',
'summary': 'E-Invoicing, Universal Business Language (UBL 2.0), e-fff protocol',
'description': """
Universal Business Language (UBL <http://ubl.xml.org/>`_) is a library of standard electronic XML business documents such as
invoices. The UBL standard became the `ISO/IEC 19845
<http://www.iso.org/iso/catalogue_detail.htm?csnumber=66370>`_ standard in January 2016
(cf the `official announce <http://www.prweb.com/releases/2016/01/prweb13186919.htm>`_).
Belgian e-invoicing uses the UBL 2.0 using the e-fff protocol.
""",
'depends': ['account', 'l10n_be'],
'data': [
'data/ubl_invoice_templates.xml',
],
'installable': True,
'auto_install': False,
}
@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="ubl_party">
<!-- This template must be called with a partner_id -->
<cac:Party
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:WebsiteURI
t-if="record.website"
t-esc="record.website"/>
<cac:PartyName>
<cbc:Name t-esc="record.name"/>
</cac:PartyName>
<cac:Language t-if="record.lang">
<cbc:LocaleCode t-esc="record.lang"/>
</cac:Language>
<cac:PostalAddress>
<cbc:StreetName
t-if="record.street"
t-esc="record.street"/>
<cbc:AdditionalStreetName
t-if="record.street2"
t-esc="record.street2"/>
<cbc:CityName
t-if="record.city"
t-esc="record.city"/>
<cbc:PostalZone
t-if="record.zip"
t-esc="record.zip"/>
<cbc:CountrySubentity
t-if="record.state_id"
t-esc="record.state_id.name"/>
<cbc:CountrySubentityCode
t-if="record.state_id"
t-esc="record.state_id.code"/>
<cac:Country
t-if="record.country_id">
<cbc:IdentificationCode t-esc="record.country_id.code"/>
<cbc:Name t-esc="record.country_id.name"/>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme t-if="record.vat">
<cbc:RegistrationName t-esc="record.name"/>
<cbc:CompanyID t-esc="record.sanitized_vat"/>
<cac:TaxScheme>
<cbc:ID
schemeID="UN/ECE 5153"
schemeAgencyID="6"
>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:Contact>
<cbc:Name t-esc="record.name"/>
<cbc:Telephone
t-if="record.phone"
t-esc="record.phone"/>
<cbc:ElectronicMail
t-if="record.email"
t-esc="record.email"/>
</cac:Contact>
</cac:Party>
</template>

<template id="ubl_invoice_line">
<t t-set="taxes" t-value="record._l10n_be_edi_get_taxes_values()"/>
<cac:InvoiceLine
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:ID t-esc="record.id"/>
<cbc:Note
t-if="record.discount"
t-esc="'Discount (%s %)' % record.discount"/>
<cbc:InvoicedQuantity
t-esc="record.quantity"/>
<cbc:LineExtensionAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.price_subtotal"/>
<cac:TaxTotal t-if="taxes">
<cbc:TaxAmount
t-att-currencyID="record.currency_id.name"
t-esc="taxes['amount']"/>
<!--<cac:TaxSubtotal-->
<!--t-foreach="taxes['taxes']"-->
<!--t-as="tax">-->
<!--<cbc:TaxAmount-->
<!--t-att-currencyID="record.currency_id.name"-->
<!--t-esc="tax['amount']"/>-->
<!--<cbc:Percent t-esc="tax['tax'].amount"/>-->
<!--</cac:TaxSubtotal>-->
</cac:TaxTotal>
<cac:Item>
<cbc:Description t-esc="record.l10n_be_edi_description"/>
<cbc:Name t-esc="record.l10n_be_edi_product_name"/>
<cac:SellersItemIdentification t-if="record.product_id.default_code">
<cbc:ID t-esc="record.product_id.default_code"/>
</cac:SellersItemIdentification>
<cac:AdditionalItemProperty
t-foreach="record.product_id.attribute_value_ids"
t-as="attribute_value_id">
<cbc:Name t-esc="attribute_value_id.attribute_id.name"/>
<cbc:Value t-esc="attribute_value_id.name"/>
</cac:AdditionalItemProperty>
</cac:Item>
<cac:Price>
<cbc:PriceAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.price_subtotal"/>
<cbc:BaseQuantity t-esc="record.quantity"/>
</cac:Price>
</cac:InvoiceLine>
</template>

<template id="ubl_invoice">
<Invoice
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:ID t-esc="record.number"/>
<cbc:IssueDate t-esc="record.date_invoice"/>
<cbc:InvoiceTypeCode t-esc="380 if record.type == 'out_invoice' else 381"/>
<cbc:Note
t-if="record.comment"
t-esc="record.comment"/>
<cbc:DocumentCurrencyCode t-esc="record.currency_id.name"/>
<cac:AccountingSupplierParty t-call="l10n_be_edi.ubl_party">
<t t-set="record" t-value="record.company_id.partner_id.commercial_partner_id"/>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty t-call="l10n_be_edi.ubl_party">
<t t-set="record" t-value="record.partner_id.commercial_partner_id"/>
</cac:AccountingCustomerParty>
<cac:PaymentMeans>
<cbc:PaymentMeansCode
listID="UN/ECE 4461"
t-esc="42 if record.journal_id.bank_account_id else 31"/>
<cbc:PaymentDueDate t-esc="record.date_due"/>
<cac:PayeeFinancialAccount t-if="record.journal_id.bank_account_id and record.journal_id.bank_account_id.acc_number">
<cbc:ID schemeName="IBAN" t-esc="record.journal_id.bank_account_id.acc_number"/>
<cac:FinancialInstitutionBranch t-if="record.journal_id.bank_account_id.bank_bic">
<cac:FinancialInstitution>
<cbc:ID schemeName="BIC" t-esc="record.journal_id.bank_account_id.bank_bic"/>
</cac:FinancialInstitution>
</cac:FinancialInstitutionBranch>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:PaymentTerms t-if="record.payment_term_id">
<cbc:Note t-esc="record.payment_term_id.name"/>
</cac:PaymentTerms>
<cac:TaxTotal t-if="not record.amount_tax == 0">
<cbc:TaxAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.amount_tax"/>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.amount_untaxed"/>
<cbc:TaxExclusiveAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.amount_untaxed"/>
<cbc:TaxInclusiveAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.amount_total"/>
<cbc:PrepaidAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.amount_total - record.residual"/>
<cbc:PayableAmount
t-att-currencyID="record.currency_id.name"
t-esc="record.residual"/>
</cac:LegalMonetaryTotal>
<t
t-foreach="record.invoice_line_ids"
t-as="invoice_line_id"
t-call="l10n_be_edi.ubl_invoice_line">
<t t-set="record" t-value="invoice_line_id"/>
</t>
</Invoice>
</template>

<template id="ubl_invoice_e_fff" inherit_id="l10n_be_edi.ubl_invoice" primary="True">
<xpath expr=".//{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}DocumentCurrencyCode[1]" position="after">
<t t-if="attachment_binary">
<t
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:LineCountNumeric t-esc="len(record.invoice_line_ids)"/>
<cac:AdditionalDocumentReference>
<cbc:ID t-esc="document_reference"/>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject
mimeCode="application/pdf"
t-esc="attachment_binary"/>
</cac:Attachment>
</cac:AdditionalDocumentReference>
</t>
</t>
</xpath>
</template>
</data>
</odoo>
Oops, something went wrong.

0 comments on commit 4c4cb42

Please sign in to comment.
You can’t perform that action at this time.