Skip to content

Commit

Permalink
Merge PR #1056 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by sergiocorato
  • Loading branch information
OCA-git-bot committed Aug 24, 2023
2 parents db603d9 + 0b30aa7 commit d862760
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions account_financial_report/report/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,19 @@ def _update_account_group_child_values(self):

def _add_account_group_account_values(self):
"""Compute values for report_trial_balance_account group in child."""
# Since Postgres 14, the argument to array_cat must be
# anycompatiblearray instead of anyarray. See
# <https://www.postgresql.org/docs/14/release-14.html#id-1.11.6.13.4>.
# We detect the version and use the correct type as needed.
array_type = (
"anycompatiblearray" if self.env.cr.connection.server_version >= 140000
else "anyarray"
)
query_update_account_group = """
DROP AGGREGATE IF EXISTS array_concat_agg(anyarray);
CREATE AGGREGATE array_concat_agg(anyarray) (
DROP AGGREGATE IF EXISTS array_concat_agg({array_type});
CREATE AGGREGATE array_concat_agg({array_type}) (
SFUNC = array_cat,
STYPE = anyarray
STYPE = {array_type}
);
WITH aggr AS(WITH computed AS (WITH RECURSIVE cte AS (
SELECT account_group_id, account_group_id AS parent_id,
Expand Down Expand Up @@ -516,7 +524,7 @@ def _add_account_group_account_values(self):
FROM aggr
WHERE report_trial_balance_account.account_group_id = aggr.account_group_id
AND report_trial_balance_account.report_id = %s
"""
""".format(array_type=array_type)
query_update_account_params = (self.id, self.id, self.id,)
self.env.cr.execute(query_update_account_group,
query_update_account_params)
Expand Down

0 comments on commit d862760

Please sign in to comment.