New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0 Import regular PDF invoices (via invoice2data), generate and import UBL and ZUGFeRD invoices #122

Closed
wants to merge 126 commits into
base: 8.0
from

Conversation

Projects
None yet
@alexis-via
Contributor

alexis-via commented Dec 25, 2015

No description provided.

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Dec 26, 2015

Contributor

This PR is Akretion's Christmas present to the Odoo community ! You can read the story behind the development of this module with some screenshots here: http://www.akretion.com/blog/akretions-christmas-present-for-the-odoo-community

We hope that you will like our present ! :) The README gives detailed instructions on how to install, configure and use the module.

Contributor

alexis-via commented Dec 26, 2015

This PR is Akretion's Christmas present to the Odoo community ! You can read the story behind the development of this module with some screenshots here: http://www.akretion.com/blog/akretions-christmas-present-for-the-odoo-community

We hope that you will like our present ! :) The README gives detailed instructions on how to install, configure and use the module.

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Dec 26, 2015

Contributor

Travis is in fact green (the red comes from a bad Transiflex password and some missing modules error, but unrelated to this module).

Contributor

alexis-via commented Dec 26, 2015

Travis is in fact green (the red comes from a bad Transiflex password and some missing modules error, but unrelated to this module).

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Dec 29, 2015

Contributor

FYI, I'm currently thinking about renaming the module from "account_invoice_pdf_import" to "account_invoice_import", because I would like to be able to import PDF files or XML files. I'm looking at how the invoicing system of the suppliers of the French administration works (Chorus), and it seems that they accept direct XML import, and not just PDF. So it may become a normal practise for a few "special" suppliers/customers to send XML files instead of PDF, and it would be better to handle both with the same module.

It's the time to take the good decision on the module name, because it's a pain to change the name of the module later on.

Contributor

alexis-via commented Dec 29, 2015

FYI, I'm currently thinking about renaming the module from "account_invoice_pdf_import" to "account_invoice_import", because I would like to be able to import PDF files or XML files. I'm looking at how the invoicing system of the suppliers of the French administration works (Chorus), and it seems that they accept direct XML import, and not just PDF. So it may become a normal practise for a few "special" suppliers/customers to send XML files instead of PDF, and it would be better to handle both with the same module.

It's the time to take the good decision on the module name, because it's a pain to change the name of the module later on.

@sbidoul

This comment has been minimized.

Show comment
Hide comment
@sbidoul

sbidoul Dec 29, 2015

Member

@alexis-via you could do a base module with addons modules to handle specific formats. Similar to bank_statement_import & co...

Member

sbidoul commented Dec 29, 2015

@alexis-via you could do a base module with addons modules to handle specific formats. Similar to bank_statement_import & co...

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Dec 29, 2015

Contributor

@sbidoul yes, it's a good idea. But this PR is for the "base" module, and my question is: should I remove 'pdf' from the name of this base module or not. I think I'll remove it and the name will be "account_invoice_import" because it is more generic. This module would support PDF and XML (CII and UBL), and other non-standard or exotic formats would be supported by additionnal modules that extend this module.

Contributor

alexis-via commented Dec 29, 2015

@sbidoul yes, it's a good idea. But this PR is for the "base" module, and my question is: should I remove 'pdf' from the name of this base module or not. I think I'll remove it and the name will be "account_invoice_import" because it is more generic. This module would support PDF and XML (CII and UBL), and other non-standard or exotic formats would be supported by additionnal modules that extend this module.

@sbidoul

This comment has been minimized.

Show comment
Hide comment
@sbidoul

sbidoul Dec 29, 2015

Member

+1 to remove pdf from the name.

Member

sbidoul commented Dec 29, 2015

+1 to remove pdf from the name.

@alexis-via alexis-via changed the title from 8.0 add account_invoice_pdf_import to 8.0 add account_invoice_import Jan 2, 2016

@brother-bernard

This comment has been minimized.

Show comment
Hide comment
@brother-bernard

brother-bernard Jan 6, 2016

👍 using this code in production

brother-bernard commented Jan 6, 2016

👍 using this code in production

@MichelGuenard

This comment has been minimized.

Show comment
Hide comment
@MichelGuenard

MichelGuenard Jan 8, 2016

I am an Odoo Saas online user V8 and I am NOT sure if I can use this new module, which will highly ease my work as a lazzy accountant! More seriously this will fill partially the gap of no-EDI modules available with Odoo.
In case my online database allows to use such module, could someone tell me how to achieve this because I am totally new with Github and I do not understand how to download the module in order to import it with my Odoo system.
Many thanks to Akretion for this contribution

MichelGuenard commented Jan 8, 2016

I am an Odoo Saas online user V8 and I am NOT sure if I can use this new module, which will highly ease my work as a lazzy accountant! More seriously this will fill partially the gap of no-EDI modules available with Odoo.
In case my online database allows to use such module, could someone tell me how to achieve this because I am totally new with Github and I do not understand how to download the module in order to import it with my Odoo system.
Many thanks to Akretion for this contribution

@elicoidal

This comment has been minimized.

Show comment
Hide comment
@elicoidal

elicoidal Jan 8, 2016

elicoidal commented Jan 8, 2016

@MichelGuenard

This comment has been minimized.

Show comment
Hide comment
@MichelGuenard

MichelGuenard Jan 8, 2016

Thanks for this confirmation. I will consider a new system allowing the OCA modules.

MichelGuenard commented Jan 8, 2016

Thanks for this confirmation. I will consider a new system allowing the OCA modules.

@sebnege

This comment has been minimized.

Show comment
Hide comment
@sebnege

sebnege Jan 29, 2016

+1: it works well, using it in production

sebnege commented Jan 29, 2016

+1: it works well, using it in production

@AlexandreFournier

This comment has been minimized.

Show comment
Hide comment
@AlexandreFournier

AlexandreFournier commented Jan 29, 2016

+1

@cdubuit

This comment has been minimized.

Show comment
Hide comment
@cdubuit

cdubuit Feb 1, 2016

👍 using this PR in production

cdubuit commented Feb 1, 2016

👍 using this PR in production

@alexis-via alexis-via changed the title from 8.0 add account_invoice_import to 8.0 Import regular PDF invoices (via invoice2data), generate and import ZUGFeRD invoices Feb 22, 2016

@OSguard

This comment has been minimized.

Show comment
Hide comment
@OSguard

OSguard Feb 29, 2016

Should ZUGFeRD be part of OCA/l18n-germany ?

OSguard commented Feb 29, 2016

Should ZUGFeRD be part of OCA/l18n-germany ?

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Feb 29, 2016

Contributor

@OSguard ZUGFeRD is such a great standard that it should not be limited to german companies ! As you have seen, the implementation has been developped by a French company and is currently used when invoicing between French companies (Akretion and its French customers) :)

More seriously, that's a good question. I know that the standard has been written by a German standardisation body, but I read that they don't only target Germany but they would like to see this standard used internationally (I'll try to find that reference again). On my side, I would like to see this great standard used through-out Europe and also internationally.

Contributor

alexis-via commented Feb 29, 2016

@OSguard ZUGFeRD is such a great standard that it should not be limited to german companies ! As you have seen, the implementation has been developped by a French company and is currently used when invoicing between French companies (Akretion and its French customers) :)

More seriously, that's a good question. I know that the standard has been written by a German standardisation body, but I read that they don't only target Germany but they would like to see this standard used internationally (I'll try to find that reference again). On my side, I would like to see this great standard used through-out Europe and also internationally.

@OSguard

This comment has been minimized.

Show comment
Hide comment
@OSguard

OSguard Feb 29, 2016

It is developed by a a german ministerie and compatible with eu laws. They hand the draft over to make it standard to EU but the process is ongoing. I don't know if there other counter concepts to become standard.
So it is law in Germany, you can may use it in other countries as well.
So OCA/l18n-eu do not exist. But the important part that we have a free implementation inside the OCA where it located just to have clear rules.

OSguard commented Feb 29, 2016

It is developed by a a german ministerie and compatible with eu laws. They hand the draft over to make it standard to EU but the process is ongoing. I don't know if there other counter concepts to become standard.
So it is law in Germany, you can may use it in other countries as well.
So OCA/l18n-eu do not exist. But the important part that we have a free implementation inside the OCA where it located just to have clear rules.

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Feb 29, 2016

Contributor

@OSguard I think that this ZUGFeRD standard should be used by anybody from any country who want to exchange electronic invoices. So, hiding this module inside l10n-xxx is probably not the best way to give visibility to this great feature. Electronic invoices are the future of invoices, not just for Germany or Europe, but to the whole world ! And ZUGFeRD is based on international formats such as Cross Industry Invoice (CII) of UN/CEFACT, which is designed for the whole world. I must say that I hesitated in naming the module account_invoice_zugferd ; I could have named it account_invoice_cii, but the embedding of the XML inside the PDF has been specified by ZUGFeRD so I decided to name it zugferd...

Contributor

alexis-via commented Feb 29, 2016

@OSguard I think that this ZUGFeRD standard should be used by anybody from any country who want to exchange electronic invoices. So, hiding this module inside l10n-xxx is probably not the best way to give visibility to this great feature. Electronic invoices are the future of invoices, not just for Germany or Europe, but to the whole world ! And ZUGFeRD is based on international formats such as Cross Industry Invoice (CII) of UN/CEFACT, which is designed for the whole world. I must say that I hesitated in naming the module account_invoice_zugferd ; I could have named it account_invoice_cii, but the embedding of the XML inside the PDF has been specified by ZUGFeRD so I decided to name it zugferd...

@rafaelbn

This comment has been minimized.

Show comment
Hide comment
@rafaelbn

rafaelbn Mar 5, 2016

Member

Hi, thanks for this contribution. Of course this is World-Wide interest. I would like to test ii, could any one add dependencies please?

Runbot fails here:

2016-03-03 00:09:11     CRITICAL    server  openerp.service.server:942 preload_registries

Failed to initialize database `3142975-122-5e7e44-all`.
Traceback (most recent call last):
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/service/server.py", line 929, in preload_registries
    registry = RegistryManager.new(dbname, update_module=update_module)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/modules/loading.py", line 319, in load_modules
    modobj.button_install(cr, SUPERUSER_ID, ids)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/addons/base/module/module.py", line 414, in button_install
    self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context=context)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/addons/base/module/module.py", line 405, in state_update
    self.check_external_dependencies(module.name, newstate)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/addons/base/module/module.py", line 378, in check_external_dependencies
    raise orm.except_orm(_('Error'), msg % (module_name, e.args[0]))
except_orm: ('Error', u'Unable to install module "account_invoice_import" because an external dependency is not met: No module named invoice2data')
Member

rafaelbn commented Mar 5, 2016

Hi, thanks for this contribution. Of course this is World-Wide interest. I would like to test ii, could any one add dependencies please?

Runbot fails here:

2016-03-03 00:09:11     CRITICAL    server  openerp.service.server:942 preload_registries

Failed to initialize database `3142975-122-5e7e44-all`.
Traceback (most recent call last):
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/service/server.py", line 929, in preload_registries
    registry = RegistryManager.new(dbname, update_module=update_module)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/modules/loading.py", line 319, in load_modules
    modobj.button_install(cr, SUPERUSER_ID, ids)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/addons/base/module/module.py", line 414, in button_install
    self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context=context)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/addons/base/module/module.py", line 405, in state_update
    self.check_external_dependencies(module.name, newstate)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3142975-122-5e7e44/openerp/addons/base/module/module.py", line 378, in check_external_dependencies
    raise orm.except_orm(_('Error'), msg % (module_name, e.args[0]))
except_orm: ('Error', u'Unable to install module "account_invoice_import" because an external dependency is not met: No module named invoice2data')
@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Mar 6, 2016

Contributor

@rafaelbn I updated .travis.yml to add the invoice2data lib... but I don't know which file I should update for runbot...

Contributor

alexis-via commented Mar 6, 2016

@rafaelbn I updated .travis.yml to add the invoice2data lib... but I don't know which file I should update for runbot...

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Mar 6, 2016

Contributor

It seems that there is a pb in Travis environment: it doesn't have wkhtmltopdf, cf travis logs:

File "/home/travis/odoo-8.0/addons/report/models/report.py", line 54, in _get_wkhtmltopdf_bin
raise IOError
IOError
Contributor

alexis-via commented Mar 6, 2016

It seems that there is a pb in Travis environment: it doesn't have wkhtmltopdf, cf travis logs:

File "/home/travis/odoo-8.0/addons/report/models/report.py", line 54, in _get_wkhtmltopdf_bin
raise IOError
IOError
@pedrobaeza

This comment has been minimized.

Show comment
Hide comment
@pedrobaeza

pedrobaeza Mar 6, 2016

Contributor

@alexis-via, I see that you already figure out how to add wkhtmltopdf.

I have added the dependencies on runbot and launch a rebuild. Let's see if all goes well.

Can you please squash commits a bit, because there are lots of very tiny commits.

Contributor

pedrobaeza commented Mar 6, 2016

@alexis-via, I see that you already figure out how to add wkhtmltopdf.

I have added the dependencies on runbot and launch a rebuild. Let's see if all goes well.

Can you please squash commits a bit, because there are lots of very tiny commits.

@RoelAdriaans

This comment has been minimized.

Show comment
Hide comment
@RoelAdriaans

RoelAdriaans Mar 15, 2016

Contributor

Testing this module, looks very interesting! We are also interested in porting and using this module with UBL invoices, because that seems to be the default in the Netherlands.

Found a usability issue: In Import Supplier Invoices, the Partners tree forces me to create a new partner, I cannot select current partner.
This is now a 2 step process, first create a account.invoice.import.config, then go to a partner and select this import config.
(Tested on OCA runbot and local machine with latest odoo 8.0 code)

Contributor

RoelAdriaans commented Mar 15, 2016

Testing this module, looks very interesting! We are also interested in porting and using this module with UBL invoices, because that seems to be the default in the Netherlands.

Found a usability issue: In Import Supplier Invoices, the Partners tree forces me to create a new partner, I cannot select current partner.
This is now a 2 step process, first create a account.invoice.import.config, then go to a partner and select this import config.
(Tested on OCA runbot and local machine with latest odoo 8.0 code)

@RoelAdriaans

This comment has been minimized.

Show comment
Hide comment
@RoelAdriaans

RoelAdriaans Mar 15, 2016

Contributor

Runbot error when printing an customer invoice:

Traceback (most recent call last):
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/report/controllers/main.py", line 116, in report_download
    response = self.report_routes(reportname, docids=docids, converter='pdf')
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/http.py", line 405, in response_wrap
    response = f(*args, **kw)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/report/controllers/main.py", line 65, in report_routes
    pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=options_data, context=context)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/account_invoice_zugferd/models/report.py", line 28, in get_pdf
    pdf_content)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/account_invoice_zugferd/models/account_invoice.py", line 746, in regular_pdf_invoice_to_zugferd_invoice
    new_pdf_filestream.appendPagesFromReader(original_pdf)
AttributeError: 'PdfFileWriter' object has no attribute 'appendPagesFromReader'
Contributor

RoelAdriaans commented Mar 15, 2016

Runbot error when printing an customer invoice:

Traceback (most recent call last):
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/report/controllers/main.py", line 116, in report_download
    response = self.report_routes(reportname, docids=docids, converter='pdf')
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/http.py", line 405, in response_wrap
    response = f(*args, **kw)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/report/controllers/main.py", line 65, in report_routes
    pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=options_data, context=context)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/account_invoice_zugferd/models/report.py", line 28, in get_pdf
    pdf_content)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3143772-122-937a9d/openerp/addons/account_invoice_zugferd/models/account_invoice.py", line 746, in regular_pdf_invoice_to_zugferd_invoice
    new_pdf_filestream.appendPagesFromReader(original_pdf)
AttributeError: 'PdfFileWriter' object has no attribute 'appendPagesFromReader'

alexis-via added some commits Aug 27, 2016

Rename base_phone_business_document_import to base_business_document_…
…import_phone for consistency

Add connector-telephony in oca_dependencies.txt
Use StreetName/AdditionalStreetName instead of AddressLine blocks, be…
…cause only the first one is accepted by Chorus Factures for example.
Update UBL methods to generate lines
Add UBL methods to generate some tax blocks
Add partner identification hook in UBL XML party block generation
Print numbers with the approriate number of digits in the XML

@alexis-via alexis-via changed the title from 8.0 Import regular PDF invoices (via invoice2data), generate and import ZUGFeRD invoices, import UBL invoices to 8.0 Import regular PDF invoices (via invoice2data), generate and import UBL and ZUGFeRD invoices Sep 26, 2016

alexis-via added some commits Sep 28, 2016

FIX Don't use _inherit = ['business.document.import']
because we want to have access to the code of the modules that inherit business.document.import
account_invoice_import_invoice2data: allow to use both a local templa…
…te dir and the built-in templates

Also allow to use only a local template dir
README updated to explain how to configure all this
Transfer log level of Odoo to invoice2data lib
Special thanks to Sébastien Beau for his help to achieve this
'invoice2data_templates_dir', False)
logger.debug(
'invoice2data local_templates_dir=%s', local_templates_dir)
templates = None

This comment has been minimized.

@rousseldenis

rousseldenis Oct 3, 2016

Contributor

Should be templates = []

@rousseldenis

rousseldenis Oct 3, 2016

Contributor

Should be templates = []

@rousseldenis

This comment has been minimized.

Show comment
Hide comment
@rousseldenis

rousseldenis Oct 4, 2016

Contributor

@alexis-via It seems that Zugferd validation does not pass on data (Structure is ok).
Number of decimals is 2 except for rebate (4).
https://www.din-zugferd-validation.org

Should we cast data ?

Contributor

rousseldenis commented Oct 4, 2016

@alexis-via It seems that Zugferd validation does not pass on data (Structure is ok).
Number of decimals is 2 except for rebate (4).
https://www.din-zugferd-validation.org

Should we cast data ?

@alexis-via

This comment has been minimized.

Show comment
Hide comment
@alexis-via

alexis-via Oct 11, 2016

Contributor

Moved to edi project.

Contributor

alexis-via commented Oct 11, 2016

Moved to edi project.

@alexis-via alexis-via closed this Oct 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment