Skip to content

Commit

Permalink
[18.0][MIG] migration partner_statement to 18.0
Browse files Browse the repository at this point in the history
+ pre-commit adjustment
  • Loading branch information
psugne committed Jan 23, 2025
1 parent 56d0073 commit ecf7e83
Show file tree
Hide file tree
Showing 14 changed files with 368 additions and 255 deletions.
15 changes: 8 additions & 7 deletions partner_statement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Partner Statement
=================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand All @@ -17,13 +17,13 @@ Partner Statement
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-reporting/tree/17.0/partner_statement
:target: https://github.com/OCA/account-financial-reporting/tree/18.0/partner_statement
:alt: OCA/account-financial-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-reporting-17-0/account-financial-reporting-17-0-partner_statement
:target: https://translation.odoo-community.org/projects/account-financial-reporting-18-0/account-financial-reporting-18-0-partner_statement
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -124,7 +124,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20partner_statement%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20partner_statement%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -144,6 +144,7 @@ Contributors
- Lois Rilo <lois.rilo@forgeflow.com>
- Dhara Solanki <dhara.solanki@initos.com>
- Danny Adair <danny@o4sb.com>
- Ugnė Sinkevičienė <ugne@versada.eu>

Maintainers
-----------
Expand All @@ -164,8 +165,8 @@ promote its widespread use.

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-MiquelRForgeFlow|
|maintainer-MiquelRForgeFlow|

This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/17.0/partner_statement>`_ project on GitHub.
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/18.0/partner_statement>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion partner_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Partner Statement",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Accounting & Finance",
"summary": "OCA Financial Reports",
"author": "ForgeFlow, Odoo Community Association (OCA)",
Expand Down
20 changes: 10 additions & 10 deletions partner_statement/report/activity_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from collections import defaultdict

from odoo import _, api, models
from odoo import api, models

from .outstanding_statement import OutstandingStatement

Expand Down Expand Up @@ -48,7 +48,7 @@ def _initial_balance_sql_q1(self, partners, date_start, account_type):
WHERE l2.date < %(date_start)s
) as pc ON pc.credit_move_id = l.id
WHERE l.partner_id IN %(partners)s
AND l.date < %(date_start)s AND not l.blocked
AND l.date < %(date_start)s
AND m.state IN ('posted')
AND aa.account_type = %(account_type)s
AND (
Expand Down Expand Up @@ -120,7 +120,7 @@ def _get_account_initial_balance(
def _display_activity_lines_sql_q1(
self, partners, date_start, date_end, account_type
):
payment_ref = _("Payment")
payment_ref = self.env._("Payment")
return str(
self._cr.mogrify(
"""
Expand All @@ -137,7 +137,7 @@ def _display_activity_lines_sql_q1(
THEN %(payment_ref)s
ELSE m.ref
END as case_ref,
l.blocked, l.currency_id, l.company_id,
l.currency_id, l.company_id,
sum(CASE WHEN (l.currency_id is not null AND l.amount_currency > 0.0)
THEN l.amount_currency
ELSE l.debit
Expand All @@ -163,7 +163,7 @@ def _display_activity_lines_sql_q1(
CASE WHEN (aj.type IN ('sale', 'purchase'))
THEN l.name
ELSE '/'
END, case_ref, l.blocked, l.currency_id, l.company_id
END, case_ref, l.currency_id, l.company_id
""",
locals(),
),
Expand All @@ -176,7 +176,7 @@ def _display_activity_lines_sql_q2(self, sub, company_id):
f"""
SELECT {sub}.partner_id, {sub}.move_id, {sub}.date, {sub}.date_maturity,
{sub}.name, {sub}.case_ref as ref, {sub}.debit, {sub}.credit, {sub}.ids,
{sub}.debit-{sub}.credit as amount, {sub}.blocked,
{sub}.debit-{sub}.credit as amount,
COALESCE({sub}.currency_id, c.currency_id) AS currency_id
FROM {sub}
JOIN res_company c ON (c.id = {sub}.company_id)
Expand All @@ -200,7 +200,7 @@ def _get_account_display_lines(
Q2 AS ({})
SELECT partner_id, move_id, date, date_maturity, ids,
COALESCE(name, '') as name, COALESCE(ref, '') as ref,
debit, credit, amount, blocked, currency_id
debit, credit, amount, currency_id
FROM Q2
ORDER BY date, date_maturity, move_id""".format(
self._display_activity_lines_sql_q1(
Expand Down Expand Up @@ -230,7 +230,7 @@ def _display_activity_reconciled_lines_sql_q2(self, sub, date_end):
self._cr.mogrify(
f"""
SELECT l.id as rel_id, m.name AS move_id, l.partner_id, l.date, l.name,
l.blocked, l.currency_id, l.company_id, {sub}.id,
l.currency_id, l.company_id, {sub}.id,
CASE WHEN l.ref IS NOT NULL
THEN l.ref
ELSE m.ref
Expand Down Expand Up @@ -269,7 +269,7 @@ def _display_activity_reconciled_lines_sql_q2(self, sub, date_end):
THEN l.ref
ELSE m.ref
END, {sub}.id,
l.blocked, l.currency_id, l.balance, l.amount_currency, l.company_id
l.currency_id, l.balance, l.amount_currency, l.company_id
""",
locals(),
),
Expand All @@ -292,7 +292,7 @@ def _get_account_display_reconciled_lines(
Q6 AS ({})
SELECT partner_id, currency_id, move_id, date, date_maturity, debit,
credit, amount, open_amount, COALESCE(name, '') as name,
COALESCE(ref, '') as ref, blocked, id
COALESCE(ref, '') as ref, id
FROM Q6
ORDER BY date, date_maturity, move_id""".format(
self._display_activity_lines_sql_q1(
Expand Down
74 changes: 54 additions & 20 deletions partner_statement/report/activity_statement_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2021 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, models
from odoo import models

from odoo.addons.report_xlsx_helper.report.report_xlsx_format import FORMATS

Expand All @@ -26,7 +26,7 @@ class ActivityStatementXslx(models.AbstractModel):

def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
report_name = _("Activity Statement")
report_name = self.env._("Activity Statement")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = f" - {company.name} - {company.currency_id.name}"
Expand All @@ -38,10 +38,12 @@ def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
currency_data = partner_data.get("currencies", {}).get(currency.id)
account_type = data.get("account_type", False)
row_pos += 2
statement_header = _(
statement_header = self.env.self.env._(
"%(payable)sStatement between %(start)s and %(end)s in %(currency)s"
) % {
"payable": account_type == "liability_payable" and _("Supplier ") or "",
"payable": account_type == "liability_payable"
and self.env._("Supplier ")
or "",
"start": partner_data.get("start"),
"end": partner_data.get("end"),
"currency": currency.display_name,
Expand All @@ -52,32 +54,51 @@ def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
)
row_pos += 1
sheet.write(
row_pos, 0, _("Reference Number"), FORMATS["format_theader_yellow_center"]
row_pos,
0,
self.env._("Reference Number"),
FORMATS["format_theader_yellow_center"],
)
sheet.write(
row_pos, 1, self.env._("Date"), FORMATS["format_theader_yellow_center"]
)
sheet.write(row_pos, 1, _("Date"), FORMATS["format_theader_yellow_center"])
sheet.merge_range(
row_pos,
2,
row_pos,
3,
_("Description"),
self.env._("Description"),
FORMATS["format_theader_yellow_center"],
)
sheet.write(
row_pos, 4, _("Original Amount"), FORMATS["format_theader_yellow_center"]
row_pos,
4,
self.env._("Original Amount"),
FORMATS["format_theader_yellow_center"],
)
sheet.write(
row_pos, 5, _("Applied Amount"), FORMATS["format_theader_yellow_center"]
row_pos,
5,
self.env._("Applied Amount"),
FORMATS["format_theader_yellow_center"],
)
sheet.write(
row_pos, 6, _("Open Amount"), FORMATS["format_theader_yellow_center"]
row_pos,
6,
self.env._("Open Amount"),
FORMATS["format_theader_yellow_center"],
)
row_pos += 1
sheet.write(
row_pos, 1, partner_data.get("prior_day"), FORMATS["format_tcell_date_left"]
)
sheet.merge_range(
row_pos, 2, row_pos, 5, _("Balance Forward"), FORMATS["format_tcell_left"]
row_pos,
2,
row_pos,
5,
self.env._("Balance Forward"),
FORMATS["format_tcell_left"],
)
sheet.write(
row_pos,
Expand Down Expand Up @@ -122,7 +143,12 @@ def _write_currency_lines(self, row_pos, sheet, partner, currency, data):
row_pos, 1, partner_data.get("end"), FORMATS["format_tcell_date_left"]
)
sheet.merge_range(
row_pos, 2, row_pos, 5, _("Ending Balance"), FORMATS["format_tcell_left"]
row_pos,
2,
row_pos,
5,
self.env._("Ending Balance"),
FORMATS["format_tcell_left"],
)
sheet.write(
row_pos,
Expand All @@ -138,7 +164,7 @@ def _write_currency_buckets(self, row_pos, sheet, partner, currency, data):
currency_data = partner_data.get("currencies", {}).get(currency.id)
if currency_data.get("buckets"):
row_pos += 2
buckets_header = _("Aging Report at %(end)s in %(currency)s") % {
buckets_header = self.env._("Aging Report at %(end)s in %(currency)s") % {
"end": partner_data.get("end"),
"currency": currency.display_name,
}
Expand Down Expand Up @@ -219,19 +245,21 @@ def generate_xlsx_report(self, workbook, data, objects):
company = self.env.user.company_id
data.update(report_model._get_report_values(data.get("partner_ids"), data))
partners = self.env["res.partner"].browse(data.get("partner_ids"))
sheet = workbook.add_worksheet(_("Activity Statement"))
sheet = workbook.add_worksheet(self.env._("Activity Statement"))
sheet.set_landscape()
row_pos = 0
sheet.merge_range(
row_pos,
0,
row_pos,
6,
_("Statement of Account from %s") % (company.display_name,),
self.env._("Statement of Account from %s") % (company.display_name,),
FORMATS["format_ws_title"],
)
row_pos += 1
sheet.write(row_pos, 1, _("Date:"), FORMATS["format_theader_yellow_right"])
sheet.write(
row_pos, 1, self.env._("Date:"), FORMATS["format_theader_yellow_right"]
)
sheet.write(
row_pos,
2,
Expand All @@ -245,7 +273,10 @@ def generate_xlsx_report(self, workbook, data, objects):
)(partner)
row_pos += 3
sheet.write(
row_pos, 1, _("Statement to:"), FORMATS["format_theader_yellow_right"]
row_pos,
1,
self.env._("Statement to:"),
FORMATS["format_theader_yellow_right"],
)
sheet.merge_range(
row_pos,
Expand All @@ -259,7 +290,7 @@ def generate_xlsx_report(self, workbook, data, objects):
sheet.write(
row_pos,
4,
_("VAT:"),
self.env._("VAT:"),
FORMATS["format_theader_yellow_right"],
)
sheet.write(
Expand All @@ -270,7 +301,10 @@ def generate_xlsx_report(self, workbook, data, objects):
)
row_pos += 1
sheet.write(
row_pos, 1, _("Statement from:"), FORMATS["format_theader_yellow_right"]
row_pos,
1,
self.env._("Statement from:"),
FORMATS["format_theader_yellow_right"],
)
sheet.merge_range(
row_pos,
Expand All @@ -284,7 +318,7 @@ def generate_xlsx_report(self, workbook, data, objects):
sheet.write(
row_pos,
4,
_("VAT:"),
self.env._("VAT:"),
FORMATS["format_theader_yellow_right"],
)
sheet.write(
Expand Down
Loading

0 comments on commit ecf7e83

Please sign in to comment.