Skip to content

Commit

Permalink
Merge pull request #233 from ecosoft-odoo/15.0-imp-l10n_th_account_wh…
Browse files Browse the repository at this point in the history
…t_cert_form_sequence-report

[15.0][IMP] l10n_th_account_wht_cert_form_sequence: add number in excel and view
  • Loading branch information
Saran440 authored Dec 19, 2024
2 parents dd16d69 + 088f356 commit c7fb72a
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 4 deletions.
1 change: 1 addition & 0 deletions l10n_th_account_wht_cert_form_sequence/__init__.py
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
2 changes: 2 additions & 0 deletions l10n_th_account_wht_cert_form_sequence/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"depends": [
"base_sequence_option",
"l10n_th_account_wht_cert_form",
"l10n_th_account_tax_report",
],
"data": [
"data/withholding_tax_cert_data.xml",
"reports/report_wht_qweb.xml",
"reports/withholding_tax_cert_form_view.xml",
"views/withholding_tax_cert_view.xml",
],
Expand Down
3 changes: 3 additions & 0 deletions l10n_th_account_wht_cert_form_sequence/reports/__init__.py
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 l10n_th_account_wht_cert_form_sequence/reports/report_wht_qweb.xml
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 l10n_th_account_wht_cert_form_sequence/reports/report_wht_xlsx.py
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down

0 comments on commit c7fb72a

Please sign in to comment.