-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] account_invoice_factur-x: Migration to 12.0
- Loading branch information
Showing
22 changed files
with
610 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models | ||
from .post_install import set_xml_format_in_pdf_invoice_to_facturx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016-2018 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Account Invoice Factur-X', | ||
'version': '10.0.1.0.0', | ||
'version': '12.0.1.0.0', | ||
'category': 'Accounting & Finance', | ||
'license': 'AGPL-3', | ||
'summary': 'Generate Factur-X/ZUGFeRD customer invoices', | ||
'author': 'Akretion,Odoo Community Association (OCA)', | ||
'author': 'Akretion, Odoo Community Association (OCA)', | ||
'website': 'http://www.akretion.com', | ||
'depends': [ | ||
'account_e-invoice_generate', | ||
'account_payment_partner', | ||
'base_zugferd', | ||
'base_vat', | ||
], | ||
'account_facturx', | ||
], | ||
'external_dependencies': {'python': ['facturx']}, | ||
'data': [ | ||
'views/res_partner.xml', | ||
'views/account_config_settings.xml', | ||
'views/res_config_settings.xml', | ||
'views/report_invoice.xml', | ||
], | ||
], | ||
'post_init_hook': 'set_xml_format_in_pdf_invoice_to_facturx', | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import company | ||
from . import account_config_settings | ||
from . import res_config_settings | ||
from . import account_invoice | ||
from . import report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016-2018 Akretion (http://www.akretion.com) | ||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models, api | ||
from odoo.addons.account_facturx.models.ir_actions_report\ | ||
import IrActionsReport as OriginIrActionsReport | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Report(models.Model): | ||
_inherit = 'report' | ||
class IrActionsReport(models.Model): | ||
_inherit = 'ir.actions.report' | ||
|
||
@api.model | ||
def get_pdf(self, docids, report_name, html=None, data=None): | ||
"""We go through that method when the PDF is generated for the 1st | ||
time and also when it is read from the attachment. | ||
This method is specific to QWeb""" | ||
pdf_content = super(Report, self).get_pdf( | ||
docids, report_name, html=html, data=data) | ||
invoice_reports = [ | ||
'account.report_invoice', | ||
'account.account_invoice_report_duplicate_main'] | ||
if report_name in invoice_reports and len(docids) == 1: | ||
invoice = self.env['account.invoice'].browse(docids[0]) | ||
if ( | ||
invoice.type in ('out_invoice', 'out_refund') and | ||
invoice.company_id.xml_format_in_pdf_invoice == | ||
'factur-x'): | ||
@api.multi | ||
def _post_pdf(self, save_in_attachment, pdf_content=None, res_ids=None): | ||
# OVERRIDE | ||
if self.model == 'account.invoice' and res_ids and len(res_ids) == 1: | ||
invoice = self.env['account.invoice'].browse(res_ids) | ||
if invoice.type in ('out_invoice', 'out_refund') and\ | ||
invoice.company_id.xml_format_in_pdf_invoice == 'factur-x': | ||
pdf_content = super( | ||
OriginIrActionsReport, self)._post_pdf( | ||
save_in_attachment, pdf_content=pdf_content, | ||
res_ids=res_ids) | ||
pdf_content = invoice.regular_pdf_invoice_to_facturx_invoice( | ||
pdf_content=pdf_content) | ||
return pdf_content | ||
|
||
# TODO : the PDF saved as attachment is NOT the good one... | ||
# but the PDF opened from the attachment is OK ! | ||
# because we don't inherit the right method. | ||
# get_pdf() calls _run_wkhtmltopdf() which generate | ||
# AND SAVE AS ATTACHMENT the report. So we need a hook inside _run_wkhtmltopdf | ||
# but there is no hook for the moment | ||
# The problem is the same in the module | ||
# OCA/reporting-engines/report_qweb_signer | ||
pdf_content) | ||
return pdf_content | ||
return super(IrActionsReport, self)._post_pdf( | ||
save_in_attachment, pdf_content=pdf_content, res_ids=res_ids) |
8 changes: 4 additions & 4 deletions
8
...actur-x/models/account_config_settings.py → ...ce_factur-x/models/res_config_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2017 Akretion - Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountConfigSettings(models.TransientModel): | ||
_inherit = 'account.config.settings' | ||
_inherit = 'res.config.settings' | ||
|
||
facturx_level = fields.Selection(related='company_id.facturx_level') | ||
facturx_level = fields.Selection(related='company_id.facturx_level', | ||
readonly=False) | ||
facturx_refund_type = fields.Selection( | ||
related='company_id.facturx_refund_type') | ||
related='company_id.facturx_refund_type', readonly=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
In the menu *Accounting > Configuration > Settings*, check these options: | ||
|
||
* *XML Format embedded in PDF invoice*: if you want to generate Factur-X invoices, this option must be set to *Factur-X (CII)* | ||
* the *Factur-X Level*: unless you have a good reason, you should keep the default value *EN 16931 (Comfort)* | ||
* *Factur-X Refund Type*: choose the type of the XML invoice for customer refunds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Firstname Lastname <email.address@example.org> (optional company website url) | ||
* Alexis de Lattre <alexis.delattre@akretion.com> | ||
* Shine IT <contact@openerp.cn> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
With this module, the PDF customer invoices and refunds generated by the Qweb reporting engine of Odoo will comply with the `Factur-X <http://fnfe-mpe.org/factur-x/>`_ standard at *EN 16931* level. The Factur-X standard is the new e-invoicing standard for France and Germany released in Beta version in July 2017. In Germany, it is also known as the `ZUGFeRD 2.0 <http://www.ferd-net.de/aktuelles/meldungen/verabschiedung-zugferd-2.0_profil-en16931.html/>`_ standard. This standard is based on `CII <http://tfig.unece.org/contents/cross-industry-invoice-cii.htm>`_ (Cross-Industry Invoice) for electronic invoicing. The great idea of the ZUGFeRD/Factur-X standard is to embed an XML file inside the PDF invoice to carry structured information about the invoice. So, with a ZUGFeRD/Factur-X PDF invoice: | ||
|
||
* no need to change your habbits and those of your customers: you can still send your PDF invoices by email as usual. | ||
* customers equiped with a modern accouting software will be able to import the invoice automatically as supplier invoice by taking advantage of the embedded XML file, | ||
* customers with an ancient accounting software will just open the PDF file with their PDF reader and manually encode the document as supplier invoice in their accounting software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This module requires the Python library *factur-x* with **version >= 0.3** developped by Akretion. Note that the factur-x library depends on PyPDF2 for the low-level PDF manipulation. To install it, run: | ||
|
||
.. code:: | ||
sudo pip install factur-x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* for Odoo v11, use the new hooks in the report code to embed the XML file inside the PDF file just after its generation and before it is saved as attachment. | ||
|
||
* develop glue modules (or use hasattr() ?) to add to the XML file pieces of information that is carried out by fields defined in other modules such as sale or stock (customer order reference, incoterms, delivery address, etc...). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
On the form view of a customer invoice/refund, just click on the *Print* button as usual to get the Factur-X-compliant PDF file. |
Oops, something went wrong.