-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_invoice_report_pagebreak
- Loading branch information
Showing
11 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,20 @@ | ||
# Copyright 2023 CGI37 (https://www.cgi37.com). | ||
# @author Pierre Verkest <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Invoice report page break", | ||
"summary": "Control Page Breaks in PDF invoice report", | ||
"version": "14.0.1.0.0", | ||
"author": "Pierre Verkest, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-invoice-reporting", | ||
"license": "AGPL-3", | ||
"category": "Accounting", | ||
"depends": [ | ||
"account", | ||
"report_qweb_table_pagebreak", | ||
], | ||
"data": [ | ||
"reports/report_invoice.xml", | ||
], | ||
"maintainers": ["petrus-v"], | ||
} |
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 @@ | ||
* Pierre Verkest <[email protected]> |
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,4 @@ | ||
Control Page Breaks in PDF invoice report. | ||
|
||
This split the main table by section and avoid | ||
as much as possible breaking page inside a section. |
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,2 @@ | ||
* Gives more controls to end users to allows to force breaking | ||
pages between any rows |
15 changes: 15 additions & 0 deletions
15
account_invoice_report_pagebreak/reports/report_invoice.xml
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,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2023 CGI37 (https://www.cgi37.com/) | ||
@author: Pierre Verkest <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
<template id="report_invoice_document" inherit_id="account.report_invoice_document"> | ||
<xpath expr="//tbody[hasclass('invoice_tbody')]/t/tr" position="attributes"> | ||
<attribute | ||
name="t-attf-data-page-break" | ||
>{{line.display_type == 'line_section' and 'avoid' or ''}}</attribute> | ||
</xpath> | ||
</template> | ||
</odoo> |
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 @@ | ||
from . import test_invoice_report_breakpage |
73 changes: 73 additions & 0 deletions
73
account_invoice_report_pagebreak/tests/test_invoice_report_breakpage.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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from lxml import html | ||
|
||
from odoo.tests import tagged | ||
from odoo.tools.image import image_data_uri | ||
|
||
from odoo.addons.account.tests.common import TestAccountReconciliationCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestInvoiceReportAvoidPageBreakInSection(TestAccountReconciliationCommon): | ||
def setUp(self): | ||
super().setUp() | ||
self.invoice = self.create_invoice_partner() | ||
self.invoice.line_ids.create( | ||
[ | ||
{ | ||
"move_id": self.invoice.id, | ||
"name": "Note 1", | ||
"display_type": "line_note", | ||
"sequence": 20, | ||
}, | ||
{ | ||
"move_id": self.invoice.id, | ||
"name": "Note 2", | ||
"display_type": "line_note", | ||
"sequence": 40, | ||
}, | ||
] | ||
) | ||
|
||
def test_sale_report_with_section(self): | ||
self.invoice.line_ids.create( | ||
[ | ||
{ | ||
"move_id": self.invoice.id, | ||
"name": "Section", | ||
"display_type": "line_section", | ||
"sequence": 30, | ||
}, | ||
] | ||
) | ||
doc = html.document_fromstring( | ||
self.env["ir.qweb"] | ||
._render( | ||
"account.report_invoice_document", | ||
values={ | ||
"o": self.invoice, | ||
"env": self.env, | ||
"company": self.env.company, | ||
"image_data_uri": image_data_uri, | ||
}, | ||
) | ||
.decode("utf-8") | ||
) | ||
self.assertEqual( | ||
len(doc.find('.//table[@style="page-break-inside: avoid"]')), 2 | ||
) | ||
|
||
def test_sale_report_without_section(self): | ||
doc = html.document_fromstring( | ||
self.env["ir.qweb"] | ||
._render( | ||
"account.report_invoice_document", | ||
values={ | ||
"o": self.invoice, | ||
"env": self.env, | ||
"company": self.env.company, | ||
"image_data_uri": image_data_uri, | ||
}, | ||
) | ||
.decode("utf-8") | ||
) | ||
self.assertFalse(doc.find('.//table[@style="page-break-inside: avoid"]')) |
1 change: 1 addition & 0 deletions
1
setup/account_invoice_report_pagebreak/odoo/addons/account_invoice_report_pagebreak
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 @@ | ||
../../../../account_invoice_report_pagebreak |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=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 |
---|---|---|
@@ -0,0 +1 @@ | ||
odoo14-addon-report-qweb-table-pagebreak @ git+https://github.com/OCA/reporting-engine.git@refs/pull/826/head#subdirectory=setup/report_qweb_table_pagebreak |