Skip to content

Commit 1c1f8e1

Browse files
TheMule71SylweKra
authored andcommitted
[IMP] l10n_it_vat_settlement_date: add XLSX report
1 parent fed0269 commit 1c1f8e1

File tree

6 files changed

+61
-30
lines changed

6 files changed

+61
-30
lines changed

l10n_it_vat_registries/report/reports.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<field name="report_type">xlsx</field>
2020
<field
2121
name="report_name"
22-
>l10n_it_vat_registries_xlsx.report_registro_iva</field>
22+
>l10n_it_vat_registries.report_registro_iva_xlsx</field>
2323
<field
2424
name="report_file"
25-
>l10n_it_vat_registries_xlsx.report_registro_iva</field>
25+
>l10n_it_vat_registries.report_registro_iva_xlsx</field>
2626
</record>
2727

2828
</odoo>

l10n_it_vat_registries/tests/test_registry.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,76 @@
88

99

1010
class TestRegistry(TransactionCase):
11-
@classmethod
12-
def setUpClass(cls):
13-
super().setUpClass()
11+
def setUp(self):
12+
super().setUp()
1413

15-
cls.test_date = fields.Date.today()
16-
cls.journal = cls.env["account.journal"].search(
14+
self.test_date = fields.Date.today()
15+
self.journal = self.env["account.journal"].search(
1716
[("type", "=", "sale")], limit=1
1817
)
19-
cls.ova = cls.env["account.account"].search(
20-
[("account_type", "=", "asset_current")],
18+
self.ova = self.env["account.account"].search(
19+
[
20+
(
21+
"user_type_id",
22+
"=",
23+
self.env.ref("account.data_account_type_current_assets").id,
24+
)
25+
],
2126
limit=1,
2227
)
23-
cls.tax = cls.env["account.tax"].create(
28+
self.tax = self.env["account.tax"].create(
2429
{
2530
"name": "Tax 10.0",
2631
"amount": 10.0,
2732
"amount_type": "fixed",
2833
}
2934
)
30-
cls.tax_registry = cls.env["account.tax.registry"].create(
35+
self.tax_registry = self.env["account.tax.registry"].create(
3136
{
3237
"name": "Sales",
3338
"layout_type": "customer",
34-
"journal_ids": [(6, 0, [cls.journal.id])],
39+
"journal_ids": [(6, 0, [self.journal.id])],
3540
}
3641
)
3742

38-
cls.invoice_line_account = (
39-
cls.env["account.account"]
43+
self.invoice_line_account = (
44+
self.env["account.account"]
4045
.search(
4146
[
4247
(
4348
"user_type_id",
4449
"=",
45-
cls.env.ref("account.data_account_type_expenses").id,
50+
self.env.ref("account.data_account_type_expenses").id,
4651
)
4752
],
4853
limit=1,
4954
)
5055
.id
5156
)
5257

53-
cls.invoice = cls.env["account.move"].create(
58+
self.invoice = self.env["account.move"].create(
5459
{
55-
"partner_id": cls.env.ref("base.res_partner_2").id,
56-
"invoice_date": cls.test_date,
60+
"partner_id": self.env.ref("base.res_partner_2").id,
61+
"invoice_date": self.test_date,
5762
"move_type": "out_invoice",
58-
"journal_id": cls.journal.id,
63+
"journal_id": self.journal.id,
5964
"invoice_line_ids": [
6065
(
6166
0,
6267
None,
6368
{
64-
"product_id": cls.env.ref("product.product_product_4").id,
69+
"product_id": self.env.ref("product.product_product_4").id,
6570
"quantity": 1.0,
6671
"price_unit": 100.0,
6772
"name": "product that cost 100",
68-
"account_id": cls.invoice_line_account,
69-
"tax_ids": [(6, 0, [cls.tax.id])],
73+
"account_id": self.invoice_line_account,
74+
"tax_ids": [(6, 0, [self.tax.id])],
7075
},
7176
)
7277
],
7378
}
7479
)
75-
cls.invoice.action_post()
80+
self.invoice.action_post()
7681

7782
def test_invoice_and_report(self):
7883
wizard = self.env["wizard.registro.iva"].create(
@@ -100,7 +105,7 @@ def test_invoice_and_report(self):
100105
# XLSX
101106
res = wizard.print_registro_xlsx()
102107

103-
report_name = "l10n_it_vat_registries_xlsx.report_registro_iva"
108+
report_name = "l10n_it_vat_registries.report_registro_iva_xlsx"
104109
domain = [
105110
("report_type", "=", "xlsx"),
106111
("report_name", "=", report_name),

l10n_it_vat_registries/wizard/report_registro_iva_xlsx.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
import logging
44

5-
from odoo import _
5+
from odoo import _, models
66
from odoo.tools.misc import formatLang
77

88
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
99
FORMATS,
1010
XLS_HEADERS,
1111
)
1212

13-
from ..models.vat_registry import ReportRegistroIva
14-
1513
_logger = logging.getLogger(__name__)
1614

1715

18-
class ReportRegistroIvaXlsx(ReportRegistroIva):
19-
_name = "report.l10n_it_vat_registries_xlsx.report_registro_iva"
20-
_inherit = "report.report_xlsx.abstract"
16+
class ReportRegistroIvaXlsx(models.AbstractModel):
17+
_name = "report.l10n_it_vat_registries.report_registro_iva_xlsx"
18+
_inherit = [
19+
"report.report_xlsx.abstract",
20+
"report.l10n_it_vat_registries.report_registro_iva",
21+
]
2122
_description = "XLSX report for VAT registries"
2223

2324
# to override

l10n_it_vat_settlement_date/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
from . import models
44
from . import reports
5+
from . import wizard
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import report_registro_iva_xlsx
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from odoo import _, models
4+
5+
6+
class ReportRegistroIvaXlsx(models.AbstractModel):
7+
_inherit = "report.l10n_it_vat_registries.report_registro_iva_xlsx"
8+
9+
def _get_vat_settlement_date_col_spec(self):
10+
ret = {
11+
"vat_settlement_date": {
12+
"header": {"value": _("VAT settlement date")},
13+
"lines": {
14+
"value": self._render(
15+
"format_date(move.l10n_it_vat_settlement_date, date_format)"
16+
)
17+
},
18+
"width": 20,
19+
}
20+
}
21+
return ret

0 commit comments

Comments
 (0)