Skip to content

Commit

Permalink
[ADD] account_invoice_report_pagebreak
Browse files Browse the repository at this point in the history
  • Loading branch information
petrus-v committed Dec 13, 2023
1 parent 8054df0 commit faf0415
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 0 deletions.
Empty file.
20 changes: 20 additions & 0 deletions account_invoice_report_pagebreak/__manifest__.py
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"],
}
1 change: 1 addition & 0 deletions account_invoice_report_pagebreak/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Pierre Verkest <[email protected]>
4 changes: 4 additions & 0 deletions account_invoice_report_pagebreak/readme/DESCRIPTION.rst
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.
2 changes: 2 additions & 0 deletions account_invoice_report_pagebreak/readme/ROADMAP.rst
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 account_invoice_report_pagebreak/reports/report_invoice.xml
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>
1 change: 1 addition & 0 deletions account_invoice_report_pagebreak/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_invoice_report_breakpage
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"]'))
6 changes: 6 additions & 0 deletions setup/account_invoice_report_pagebreak/setup.py
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,
)
1 change: 1 addition & 0 deletions test-requirements.txt
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

0 comments on commit faf0415

Please sign in to comment.