generated from OCA/oca-addons-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from ecosoft-odoo/15.0-imp-l10n_th_account_wh…
…t_cert_form_sequence-report [15.0][IMP] l10n_th_account_wht_cert_form_sequence: add number in excel and view
- Loading branch information
Showing
6 changed files
with
123 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from . import reports |
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
from . import report_wht_xlsx |
32 changes: 32 additions & 0 deletions
32
l10n_th_account_wht_cert_form_sequence/reports/report_wht_qweb.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,32 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<!-- Header Lines --> | ||
<template | ||
id="header_line_report_withholding_tax" | ||
inherit_id="l10n_th_account_tax_report.header_line_report_withholding_tax" | ||
> | ||
<xpath expr="//div[hasclass('act_as_row')]" position="inside"> | ||
<div class="act_as_cell">Number</div> | ||
</xpath> | ||
</template> | ||
<!-- Lines --> | ||
<template | ||
id="line_report_withholding_tax" | ||
inherit_id="l10n_th_account_tax_report.line_report_withholding_tax" | ||
> | ||
<xpath expr="//div[hasclass('act_as_row')]" position="inside"> | ||
<div class="act_as_cell left"> | ||
<span t-field="line.cert_id.number" /> | ||
</div> | ||
</xpath> | ||
</template> | ||
<!-- Total Lines --> | ||
<template | ||
id="total_line_report_withholding_tax" | ||
inherit_id="l10n_th_account_tax_report.total_line_report_withholding_tax" | ||
> | ||
<xpath expr="//div[hasclass('act_as_row')]" position="inside"> | ||
<div class="act_as_cell" /> | ||
</xpath> | ||
</template> | ||
</odoo> |
81 changes: 81 additions & 0 deletions
81
l10n_th_account_wht_cert_form_sequence/reports/report_wht_xlsx.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,81 @@ | ||
# Copyright 2024 Ecosoft Co., Ltd (https://ecosoft.co.th/) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import models | ||
|
||
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import FORMATS | ||
|
||
|
||
class WithholdingTaxReportXslx(models.AbstractModel): | ||
_inherit = "report.withholding.tax.report.xlsx" | ||
|
||
def _get_ws_params(self, wb, data, obj): | ||
ws_params = super()._get_ws_params(wb, data, obj) | ||
ws_params[0]["wanted_list"].append("12_number") | ||
ws_params[0]["col_specs"]["12_number"] = { | ||
"header": {"value": "Number"}, | ||
"data": {"value": self._render("number")}, | ||
"width": 19, | ||
} | ||
return ws_params | ||
|
||
def _write_ws_lines(self, row_pos, ws, ws_params, obj): | ||
""" | ||
NOTE: V16 can hooks some method (Don't need to overwrite) | ||
Overwrite this method for adding render_spance value | ||
""" | ||
row_pos = self._write_line( | ||
ws, | ||
row_pos, | ||
ws_params, | ||
col_specs_section="header", | ||
default_format=FORMATS["format_theader_blue_center"], | ||
) | ||
ws.freeze_panes(row_pos, 0) | ||
index = 1 | ||
for line in obj.results: | ||
cancel = line.cert_id.state == "cancel" | ||
row_pos = self._write_line( | ||
ws, | ||
row_pos, | ||
ws_params, | ||
col_specs_section="data", | ||
render_space={ | ||
"sequence": index, | ||
"vat": line.cert_id.partner_id.vat or "", | ||
"display_name": not cancel | ||
and line.cert_id.partner_id.display_name | ||
or "Cancelled", | ||
"street": not cancel and line.cert_id.partner_id.street or "", | ||
"date": line.cert_id.date, | ||
"income_desc": line.wht_cert_income_desc or "", | ||
"tax": line.wht_percent / 100 or 0.00, | ||
"base_amount": not cancel and line.base or 0.00, | ||
"tax_amount": not cancel and line.amount or 0.00, | ||
"tax_payer": line.cert_id.tax_payer, | ||
"payment_id": line.cert_id.name, | ||
"number": line.cert_id.number, | ||
}, | ||
default_format=FORMATS["format_tcell_left"], | ||
) | ||
index += 1 | ||
return row_pos | ||
|
||
def _write_ws_footer(self, row_pos, ws, obj): | ||
""" | ||
NOTE: V16 can hooks some method (Don't need to overwrite) | ||
Overwrite this method to add merge range + 1 | ||
""" | ||
results = obj.results.filtered(lambda res: res.cert_id.state == "done") | ||
ws.merge_range(row_pos, 0, row_pos, 6, "") | ||
ws.merge_range(row_pos, 9, row_pos, 11, "") # change 10 to 11 | ||
ws.write_row( | ||
row_pos, 0, ["Total Balance"], FORMATS["format_theader_blue_right"] | ||
) | ||
ws.write_row( | ||
row_pos, | ||
7, | ||
[sum(results.mapped("base")), sum(results.mapped("amount")), ""], | ||
FORMATS["format_theader_blue_amount_right"], | ||
) | ||
return row_pos |
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