[IMP] account_financial_report: Refactor

TT38721
pull/917/head
Víctor Martínez 2022-09-14 18:25:46 +02:00
parent 4bd43fcbd7
commit 01efb031e1
6 changed files with 303 additions and 341 deletions

View File

@ -1,5 +1,6 @@
# © 2016 Julien Coux (Camptocamp) # © 2016 Julien Coux (Camptocamp)
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com) # Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import calendar import calendar
@ -145,6 +146,69 @@ class GeneralLedgerReport(models.AbstractModel):
pl_initial_balance["bal_curr"] += initial_balance["amount_currency"] pl_initial_balance["bal_curr"] += initial_balance["amount_currency"]
return pl_initial_balance return pl_initial_balance
def _get_gl_initial_acc(
self, account_ids, company_id, date_from, fy_start_date, base_domain
):
initial_domain_bs = self._get_initial_balances_bs_ml_domain(
account_ids, company_id, date_from, base_domain
)
initial_domain_pl = self._get_initial_balances_pl_ml_domain(
account_ids, company_id, date_from, fy_start_date, base_domain
)
return self._get_accounts_initial_balance(initial_domain_bs, initial_domain_pl)
def _prepare_gen_ld_data_item(self, gl):
res = {}
for key_bal in ["init_bal", "fin_bal"]:
res[key_bal] = {}
for key_field in ["credit", "debit", "balance", "bal_curr"]:
field_name = key_field if key_field != "bal_curr" else "amount_currency"
res[key_bal][key_field] = gl[field_name]
return res
def _prepare_gen_ld_data(self, gl_initial_acc, domain, grouped_by):
data = {}
for gl in gl_initial_acc:
acc_id = gl["account_id"][0]
data[acc_id] = self._prepare_gen_ld_data_item(gl)
data[acc_id]["id"] = acc_id
if grouped_by:
data[acc_id][grouped_by] = False
method = "_prepare_gen_ld_data_group_%s" % grouped_by
if not hasattr(self, method):
return data
return getattr(self, method)(data, domain, grouped_by)
def _prepare_gen_ld_data_group_partners(self, data, domain, grouped_by):
gl_initial_acc_prt = self.env["account.move.line"].read_group(
domain=domain,
fields=[
"account_id",
"partner_id",
"debit",
"credit",
"balance",
"amount_currency",
],
groupby=["account_id", "partner_id"],
lazy=False,
)
if gl_initial_acc_prt:
for gl in gl_initial_acc_prt:
if not gl["partner_id"]:
prt_id = 0
prt_name = "Missing Partner"
else:
prt_id = gl["partner_id"][0]
prt_name = gl["partner_id"][1]
prt_name = prt_name._value
acc_id = gl["account_id"][0]
data[acc_id][prt_id] = self._prepare_gen_ld_data_item(gl)
data[acc_id][prt_id]["id"] = prt_id
data[acc_id][prt_id]["name"] = prt_name
data[acc_id][grouped_by] = True
return data
def _get_initial_balance_data( def _get_initial_balance_data(
self, self,
account_ids, account_ids,
@ -158,6 +222,7 @@ class GeneralLedgerReport(models.AbstractModel):
analytic_tag_ids, analytic_tag_ids,
cost_center_ids, cost_center_ids,
extra_domain, extra_domain,
grouped_by,
): ):
# If explicit list of accounts is provided, # If explicit list of accounts is provided,
# don't include unaffected earnings account # don't include unaffected earnings account
@ -178,114 +243,34 @@ class GeneralLedgerReport(models.AbstractModel):
base_domain += [("analytic_account_id", "in", cost_center_ids)] base_domain += [("analytic_account_id", "in", cost_center_ids)]
if extra_domain: if extra_domain:
base_domain += extra_domain base_domain += extra_domain
initial_domain_bs = self._get_initial_balances_bs_ml_domain( gl_initial_acc = self._get_gl_initial_acc(
account_ids, company_id, date_from, base_domain
)
initial_domain_pl = self._get_initial_balances_pl_ml_domain(
account_ids, company_id, date_from, fy_start_date, base_domain account_ids, company_id, date_from, fy_start_date, base_domain
) )
gl_initial_acc = self._get_accounts_initial_balance( domain = self._get_initial_balances_bs_ml_domain(
initial_domain_bs, initial_domain_pl
)
initial_domain_acc_prt = self._get_initial_balances_bs_ml_domain(
account_ids, company_id, date_from, base_domain, acc_prt=True account_ids, company_id, date_from, base_domain, acc_prt=True
) )
gl_initial_acc_prt = self.env["account.move.line"].read_group( data = self._prepare_gen_ld_data(gl_initial_acc, domain, grouped_by)
domain=initial_domain_acc_prt, accounts_ids = list(data.keys())
fields=[
"account_id",
"partner_id",
"debit",
"credit",
"balance",
"amount_currency",
],
groupby=["account_id", "partner_id"],
lazy=False,
)
gen_ld_data = {}
for gl in gl_initial_acc:
acc_id = gl["account_id"][0]
gen_ld_data[acc_id] = {}
gen_ld_data[acc_id]["id"] = acc_id
gen_ld_data[acc_id]["partners"] = False
gen_ld_data[acc_id]["init_bal"] = {}
gen_ld_data[acc_id]["init_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id]["init_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id]["init_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id]["fin_bal"] = {}
gen_ld_data[acc_id]["fin_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id]["fin_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id]["fin_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id]["init_bal"]["bal_curr"] = gl["amount_currency"]
gen_ld_data[acc_id]["fin_bal"]["bal_curr"] = gl["amount_currency"]
partners_data = {}
partners_ids = set()
if gl_initial_acc_prt:
for gl in gl_initial_acc_prt:
if not gl["partner_id"]:
prt_id = 0
prt_name = "Missing Partner"
else:
prt_id = gl["partner_id"][0]
prt_name = gl["partner_id"][1]
prt_name = prt_name._value
if prt_id not in partners_ids:
partners_ids.add(prt_id)
partners_data.update({prt_id: {"id": prt_id, "name": prt_name}})
acc_id = gl["account_id"][0]
gen_ld_data[acc_id][prt_id] = {}
gen_ld_data[acc_id][prt_id]["id"] = prt_id
gen_ld_data[acc_id]["partners"] = True
gen_ld_data[acc_id][prt_id]["init_bal"] = {}
gen_ld_data[acc_id][prt_id]["init_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id][prt_id]["init_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id][prt_id]["init_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id][prt_id]["fin_bal"] = {}
gen_ld_data[acc_id][prt_id]["fin_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id][prt_id]["init_bal"]["bal_curr"] = gl[
"amount_currency"
]
gen_ld_data[acc_id][prt_id]["fin_bal"]["bal_curr"] = gl[
"amount_currency"
]
accounts_ids = list(gen_ld_data.keys())
unaffected_id = unaffected_earnings_account unaffected_id = unaffected_earnings_account
if unaffected_id: if unaffected_id:
if unaffected_id not in accounts_ids: if unaffected_id not in accounts_ids:
accounts_ids.append(unaffected_id) accounts_ids.append(unaffected_id)
self._initialize_account(gen_ld_data, unaffected_id, foreign_currency) data[unaffected_id] = self._initialize_data(foreign_currency)
data[unaffected_id]["id"] = unaffected_id
data[unaffected_id]["mame"] = ""
data[unaffected_id][grouped_by] = False
pl_initial_balance = self._get_pl_initial_balance( pl_initial_balance = self._get_pl_initial_balance(
account_ids, company_id, fy_start_date, foreign_currency, base_domain account_ids, company_id, fy_start_date, foreign_currency, base_domain
) )
gen_ld_data[unaffected_id]["init_bal"]["debit"] += pl_initial_balance[ for key_bal in ["init_bal", "fin_bal"]:
"debit" fields_balance = ["credit", "debit", "balance"]
] if foreign_currency:
gen_ld_data[unaffected_id]["init_bal"]["credit"] += pl_initial_balance[ fields_balance.append("bal_curr")
"credit" for field_name in fields_balance:
] data[unaffected_id][key_bal][field_name] += pl_initial_balance[
gen_ld_data[unaffected_id]["init_bal"]["balance"] += pl_initial_balance[ field_name
"balance" ]
] return data
gen_ld_data[unaffected_id]["fin_bal"]["debit"] += pl_initial_balance[
"debit"
]
gen_ld_data[unaffected_id]["fin_bal"]["credit"] += pl_initial_balance[
"credit"
]
gen_ld_data[unaffected_id]["fin_bal"]["balance"] += pl_initial_balance[
"balance"
]
if foreign_currency:
gen_ld_data[unaffected_id]["init_bal"][
"bal_curr"
] += pl_initial_balance["bal_curr"]
gen_ld_data[unaffected_id]["fin_bal"]["bal_curr"] += pl_initial_balance[
"bal_curr"
]
return gen_ld_data, partners_data, partner_ids
@api.model @api.model
def _get_move_line_data(self, move_line): def _get_move_line_data(self, move_line):
@ -370,40 +355,15 @@ class GeneralLedgerReport(models.AbstractModel):
domain += [("analytic_account_id", "in", cost_center_ids)] domain += [("analytic_account_id", "in", cost_center_ids)]
return domain return domain
@api.model def _initialize_data(self, foreign_currency):
def _initialize_partner(self, gen_ld_data, acc_id, prt_id, foreign_currency): res = {}
gen_ld_data[acc_id]["partners"] = True for key_bal in ["init_bal", "fin_bal"]:
gen_ld_data[acc_id][prt_id] = {} res[key_bal] = {}
gen_ld_data[acc_id][prt_id]["id"] = prt_id for key_field in ["balance", "credit", "debit"]:
gen_ld_data[acc_id][prt_id]["init_bal"] = {} res[key_bal][key_field] = 0.0
gen_ld_data[acc_id][prt_id]["init_bal"]["balance"] = 0.0 if foreign_currency:
gen_ld_data[acc_id][prt_id]["init_bal"]["credit"] = 0.0 res[key_bal]["bal_curr"] = 0.0
gen_ld_data[acc_id][prt_id]["init_bal"]["debit"] = 0.0 return res
gen_ld_data[acc_id][prt_id]["fin_bal"] = {}
gen_ld_data[acc_id][prt_id]["fin_bal"]["credit"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"]["debit"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"]["balance"] = 0.0
if foreign_currency:
gen_ld_data[acc_id][prt_id]["init_bal"]["bal_curr"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"]["bal_curr"] = 0.0
return gen_ld_data
def _initialize_account(self, gen_ld_data, acc_id, foreign_currency):
gen_ld_data[acc_id] = {}
gen_ld_data[acc_id]["id"] = acc_id
gen_ld_data[acc_id]["partners"] = False
gen_ld_data[acc_id]["init_bal"] = {}
gen_ld_data[acc_id]["init_bal"]["balance"] = 0.0
gen_ld_data[acc_id]["init_bal"]["credit"] = 0.0
gen_ld_data[acc_id]["init_bal"]["debit"] = 0.0
gen_ld_data[acc_id]["fin_bal"] = {}
gen_ld_data[acc_id]["fin_bal"]["credit"] = 0.0
gen_ld_data[acc_id]["fin_bal"]["debit"] = 0.0
gen_ld_data[acc_id]["fin_bal"]["balance"] = 0.0
if foreign_currency:
gen_ld_data[acc_id]["init_bal"]["bal_curr"] = 0.0
gen_ld_data[acc_id]["fin_bal"]["bal_curr"] = 0.0
return gen_ld_data
def _get_reconciled_after_date_to_ids(self, full_reconcile_ids, date_to): def _get_reconciled_after_date_to_ids(self, full_reconcile_ids, date_to):
full_reconcile_ids = list(full_reconcile_ids) full_reconcile_ids = list(full_reconcile_ids)
@ -421,6 +381,18 @@ class GeneralLedgerReport(models.AbstractModel):
rec_after_date_to_ids = [i[0] for i in rec_after_date_to_ids] rec_after_date_to_ids = [i[0] for i in rec_after_date_to_ids]
return rec_after_date_to_ids return rec_after_date_to_ids
def _prepare_ml_items(self, move_line, grouped_by):
res = []
if grouped_by == "partners":
item_id = move_line["partner_id"][0] if move_line["partner_id"] else 0
item_name = (
move_line["partner_id"][1]
if move_line["partner_id"]
else "Missing Partner"
)
res.append({"id": item_id, "name": item_name})
return res
def _get_period_ml_data( def _get_period_ml_data(
self, self,
account_ids, account_ids,
@ -430,12 +402,11 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves, only_posted_moves,
date_from, date_from,
date_to, date_to,
partners_data,
gen_ld_data, gen_ld_data,
partners_ids,
analytic_tag_ids, analytic_tag_ids,
cost_center_ids, cost_center_ids,
extra_domain, extra_domain,
grouped_by,
): ):
domain = self._get_period_domain( domain = self._get_period_domain(
account_ids, account_ids,
@ -499,33 +470,38 @@ class GeneralLedgerReport(models.AbstractModel):
full_reconcile_ids.add(rec_id) full_reconcile_ids.add(rec_id)
acc_id = move_line["account_id"][0] acc_id = move_line["account_id"][0]
ml_id = move_line["id"] ml_id = move_line["id"]
if move_line["partner_id"]:
prt_id = move_line["partner_id"][0]
partner_name = move_line["partner_id"][1]
if acc_id not in gen_ld_data.keys(): if acc_id not in gen_ld_data.keys():
gen_ld_data = self._initialize_account( gen_ld_data[acc_id] = self._initialize_data(foreign_currency)
gen_ld_data, acc_id, foreign_currency gen_ld_data[acc_id]["id"] = acc_id
) gen_ld_data[acc_id]["mame"] = move_line["account_id"][1]
gen_ld_data[acc_id][grouped_by] = False
if acc_id in acc_prt_account_ids: if acc_id in acc_prt_account_ids:
if not move_line["partner_id"]: item_ids = self._prepare_ml_items(move_line, grouped_by)
prt_id = 0 for item in item_ids:
partner_name = "Missing Partner" item_id = item["id"]
partners_ids.append(prt_id) if item_id not in gen_ld_data[acc_id]:
partners_data.update({prt_id: {"id": prt_id, "name": partner_name}}) gen_ld_data[acc_id][grouped_by] = True
if prt_id not in gen_ld_data[acc_id]: gen_ld_data[acc_id][item_id] = self._initialize_data(
gen_ld_data = self._initialize_partner( foreign_currency
gen_ld_data, acc_id, prt_id, foreign_currency )
gen_ld_data[acc_id][item_id]["id"] = item_id
gen_ld_data[acc_id][item_id]["name"] = item["name"]
gen_ld_data[acc_id][item_id][ml_id] = self._get_move_line_data(
move_line
) )
gen_ld_data[acc_id][prt_id][ml_id] = self._get_move_line_data(move_line) gen_ld_data[acc_id][item_id]["fin_bal"]["credit"] += move_line[
gen_ld_data[acc_id][prt_id]["fin_bal"]["credit"] += move_line["credit"] "credit"
gen_ld_data[acc_id][prt_id]["fin_bal"]["debit"] += move_line["debit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["balance"] += move_line[
"balance"
]
if foreign_currency:
gen_ld_data[acc_id][prt_id]["fin_bal"]["bal_curr"] += move_line[
"amount_currency"
] ]
gen_ld_data[acc_id][item_id]["fin_bal"]["debit"] += move_line[
"debit"
]
gen_ld_data[acc_id][item_id]["fin_bal"]["balance"] += move_line[
"balance"
]
if foreign_currency:
gen_ld_data[acc_id][item_id]["fin_bal"][
"bal_curr"
] += move_line["amount_currency"]
else: else:
gen_ld_data[acc_id][ml_id] = self._get_move_line_data(move_line) gen_ld_data[acc_id][ml_id] = self._get_move_line_data(move_line)
gen_ld_data[acc_id]["fin_bal"]["credit"] += move_line["credit"] gen_ld_data[acc_id]["fin_bal"]["credit"] += move_line["credit"]
@ -545,7 +521,6 @@ class GeneralLedgerReport(models.AbstractModel):
return ( return (
gen_ld_data, gen_ld_data,
accounts_data, accounts_data,
partners_data,
journals_data, journals_data,
full_reconcile_data, full_reconcile_data,
taxes_data, taxes_data,
@ -580,14 +555,14 @@ class GeneralLedgerReport(models.AbstractModel):
account.update({"move_lines": move_lines}) account.update({"move_lines": move_lines})
return account return account
def _create_account_not_show_partner( def _create_account_not_show_item(
self, account, acc_id, gen_led_data, rec_after_date_to_ids self, account, acc_id, gen_led_data, rec_after_date_to_ids, grouped_by
): ):
move_lines = [] move_lines = []
for prt_id in gen_led_data[acc_id].keys(): for prt_id in gen_led_data[acc_id].keys():
if not isinstance(prt_id, int): if not isinstance(prt_id, int):
account.update({prt_id: gen_led_data[acc_id][prt_id]}) account.update({prt_id: gen_led_data[acc_id][prt_id]})
else: elif isinstance(gen_led_data[acc_id][prt_id], dict):
for ml_id in gen_led_data[acc_id][prt_id].keys(): for ml_id in gen_led_data[acc_id][prt_id].keys():
if isinstance(ml_id, int): if isinstance(ml_id, int):
move_lines += [gen_led_data[acc_id][prt_id][ml_id]] move_lines += [gen_led_data[acc_id][prt_id][ml_id]]
@ -597,14 +572,48 @@ class GeneralLedgerReport(models.AbstractModel):
gen_led_data[acc_id]["init_bal"]["balance"], gen_led_data[acc_id]["init_bal"]["balance"],
rec_after_date_to_ids, rec_after_date_to_ids,
) )
account.update({"move_lines": move_lines, "partners": False}) account.update({"move_lines": move_lines, grouped_by: False})
return account return account
def _get_list_grouped_item(
self, data, account, rec_after_date_to_ids, hide_account_at_0, rounding
):
list_grouped = []
for data_id in data.keys():
group_item = {}
move_lines = []
if not isinstance(data_id, int):
account.update({data_id: data[data_id]})
else:
for ml_id in data[data_id].keys():
if not isinstance(ml_id, int):
group_item.update({ml_id: data[data_id][ml_id]})
else:
move_lines += [data[data_id][ml_id]]
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
move_lines = self._recalculate_cumul_balance(
move_lines,
data[data_id]["init_bal"]["balance"],
rec_after_date_to_ids,
)
group_item.update({"move_lines": move_lines})
if (
hide_account_at_0
and float_is_zero(
data[data_id]["init_bal"]["balance"],
precision_rounding=rounding,
)
and group_item["move_lines"] == []
):
continue
list_grouped += [group_item]
return account, list_grouped
def _create_general_ledger( def _create_general_ledger(
self, self,
gen_led_data, gen_led_data,
accounts_data, accounts_data,
show_partner_details, grouped_by,
rec_after_date_to_ids, rec_after_date_to_ids,
hide_account_at_0, hide_account_at_0,
): ):
@ -619,9 +628,10 @@ class GeneralLedgerReport(models.AbstractModel):
"type": "account", "type": "account",
"currency_id": accounts_data[acc_id]["currency_id"], "currency_id": accounts_data[acc_id]["currency_id"],
"centralized": accounts_data[acc_id]["centralized"], "centralized": accounts_data[acc_id]["centralized"],
"grouped_by": grouped_by,
} }
) )
if not gen_led_data[acc_id]["partners"]: if grouped_by and not gen_led_data[acc_id][grouped_by]:
account = self._create_account( account = self._create_account(
account, acc_id, gen_led_data, rec_after_date_to_ids account, acc_id, gen_led_data, rec_after_date_to_ids
) )
@ -635,51 +645,27 @@ class GeneralLedgerReport(models.AbstractModel):
): ):
continue continue
else: else:
if show_partner_details: if grouped_by:
list_partner = [] account, list_grouped = self._get_list_grouped_item(
for prt_id in gen_led_data[acc_id].keys(): gen_led_data[acc_id],
partner = {} account,
move_lines = [] rec_after_date_to_ids,
if not isinstance(prt_id, int): hide_account_at_0,
account.update({prt_id: gen_led_data[acc_id][prt_id]}) rounding,
else: )
for ml_id in gen_led_data[acc_id][prt_id].keys(): account.update({"list_grouped": list_grouped})
if not isinstance(ml_id, int):
partner.update(
{ml_id: gen_led_data[acc_id][prt_id][ml_id]}
)
else:
move_lines += [gen_led_data[acc_id][prt_id][ml_id]]
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
move_lines = self._recalculate_cumul_balance(
move_lines,
gen_led_data[acc_id][prt_id]["init_bal"]["balance"],
rec_after_date_to_ids,
)
partner.update({"move_lines": move_lines})
if (
hide_account_at_0
and float_is_zero(
gen_led_data[acc_id][prt_id]["init_bal"]["balance"],
precision_rounding=rounding,
)
and partner["move_lines"] == []
):
continue
list_partner += [partner]
account.update({"list_partner": list_partner})
if ( if (
hide_account_at_0 hide_account_at_0
and float_is_zero( and float_is_zero(
gen_led_data[acc_id]["init_bal"]["balance"], gen_led_data[acc_id]["init_bal"]["balance"],
precision_rounding=rounding, precision_rounding=rounding,
) )
and account["list_partner"] == [] and account["list_grouped"] == []
): ):
continue continue
else: else:
account = self._create_account_not_show_partner( account = self._create_account_not_show_item(
account, acc_id, gen_led_data, rec_after_date_to_ids account, acc_id, gen_led_data, rec_after_date_to_ids, grouped_by
) )
if ( if (
hide_account_at_0 hide_account_at_0
@ -735,13 +721,13 @@ class GeneralLedgerReport(models.AbstractModel):
return centralized_ml return centralized_ml
@api.model @api.model
def _get_centralized_ml(self, account, date_to): def _get_centralized_ml(self, account, date_to, grouped_by):
centralized_ml = {} centralized_ml = {}
if isinstance(date_to, str): if isinstance(date_to, str):
date_to = datetime.datetime.strptime(date_to, "%Y-%m-%d").date() date_to = datetime.datetime.strptime(date_to, "%Y-%m-%d").date()
if account["partners"]: if grouped_by and account[grouped_by]:
for partner in account["list_partner"]: for item in account["list_grouped"]:
for move_line in partner["move_lines"]: for move_line in item["move_lines"]:
centralized_ml = self._calculate_centralization( centralized_ml = self._calculate_centralization(
centralized_ml, centralized_ml,
move_line, move_line,
@ -766,21 +752,17 @@ class GeneralLedgerReport(models.AbstractModel):
date_to = data["date_to"] date_to = data["date_to"]
date_from = data["date_from"] date_from = data["date_from"]
partner_ids = data["partner_ids"] partner_ids = data["partner_ids"]
if not partner_ids:
filter_partner_ids = False
else:
filter_partner_ids = True
account_ids = data["account_ids"] account_ids = data["account_ids"]
analytic_tag_ids = data["analytic_tag_ids"] analytic_tag_ids = data["analytic_tag_ids"]
cost_center_ids = data["cost_center_ids"] cost_center_ids = data["cost_center_ids"]
show_partner_details = data["show_partner_details"] grouped_by = data["grouped_by"]
hide_account_at_0 = data["hide_account_at_0"] hide_account_at_0 = data["hide_account_at_0"]
foreign_currency = data["foreign_currency"] foreign_currency = data["foreign_currency"]
only_posted_moves = data["only_posted_moves"] only_posted_moves = data["only_posted_moves"]
unaffected_earnings_account = data["unaffected_earnings_account"] unaffected_earnings_account = data["unaffected_earnings_account"]
fy_start_date = data["fy_start_date"] fy_start_date = data["fy_start_date"]
extra_domain = data["domain"] extra_domain = data["domain"]
gen_ld_data, partners_data, partners_ids = self._get_initial_balance_data( gen_ld_data = self._get_initial_balance_data(
account_ids, account_ids,
partner_ids, partner_ids,
company_id, company_id,
@ -792,12 +774,12 @@ class GeneralLedgerReport(models.AbstractModel):
analytic_tag_ids, analytic_tag_ids,
cost_center_ids, cost_center_ids,
extra_domain, extra_domain,
grouped_by,
) )
centralize = data["centralize"] centralize = data["centralize"]
( (
gen_ld_data, gen_ld_data,
accounts_data, accounts_data,
partners_data,
journals_data, journals_data,
full_reconcile_data, full_reconcile_data,
taxes_data, taxes_data,
@ -811,33 +793,34 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves, only_posted_moves,
date_from, date_from,
date_to, date_to,
partners_data,
gen_ld_data, gen_ld_data,
partners_ids,
analytic_tag_ids, analytic_tag_ids,
cost_center_ids, cost_center_ids,
extra_domain, extra_domain,
grouped_by,
) )
general_ledger = self._create_general_ledger( general_ledger = self._create_general_ledger(
gen_ld_data, gen_ld_data,
accounts_data, accounts_data,
show_partner_details, grouped_by,
rec_after_date_to_ids, rec_after_date_to_ids,
hide_account_at_0, hide_account_at_0,
) )
if centralize: if centralize:
for account in general_ledger: for account in general_ledger:
if account["centralized"]: if account["centralized"]:
centralized_ml = self._get_centralized_ml(account, date_to) centralized_ml = self._get_centralized_ml(
account, date_to, grouped_by
)
account["move_lines"] = centralized_ml account["move_lines"] = centralized_ml
account["move_lines"] = self._recalculate_cumul_balance( account["move_lines"] = self._recalculate_cumul_balance(
account["move_lines"], account["move_lines"],
gen_ld_data[account["id"]]["init_bal"]["balance"], gen_ld_data[account["id"]]["init_bal"]["balance"],
rec_after_date_to_ids, rec_after_date_to_ids,
) )
if account["partners"]: if grouped_by and account[grouped_by]:
account["partners"] = False account[grouped_by] = False
del account["list_partner"] del account["list_grouped"]
general_ledger = sorted(general_ledger, key=lambda k: k["code"]) general_ledger = sorted(general_ledger, key=lambda k: k["code"])
return { return {
"doc_ids": [wizard_id], "doc_ids": [wizard_id],
@ -855,12 +838,11 @@ class GeneralLedgerReport(models.AbstractModel):
"show_cost_center": data["show_cost_center"], "show_cost_center": data["show_cost_center"],
"general_ledger": general_ledger, "general_ledger": general_ledger,
"accounts_data": accounts_data, "accounts_data": accounts_data,
"partners_data": partners_data,
"journals_data": journals_data, "journals_data": journals_data,
"full_reconcile_data": full_reconcile_data, "full_reconcile_data": full_reconcile_data,
"taxes_data": taxes_data, "taxes_data": taxes_data,
"centralize": centralize, "centralize": centralize,
"tags_data": tags_data, "tags_data": tags_data,
"filter_partner_ids": filter_partner_ids, "filter_partner_ids": True if partner_ids else False,
"currency_model": self.env["res.currency"], "currency_model": self.env["res.currency"],
} }

View File

@ -142,7 +142,6 @@ class GeneralLedgerXslx(models.AbstractModel):
]._get_report_values(report, data) ]._get_report_values(report, data)
general_ledger = res_data["general_ledger"] general_ledger = res_data["general_ledger"]
accounts_data = res_data["accounts_data"] accounts_data = res_data["accounts_data"]
partners_data = res_data["partners_data"]
journals_data = res_data["journals_data"] journals_data = res_data["journals_data"]
taxes_data = res_data["taxes_data"] taxes_data = res_data["taxes_data"]
tags_data = res_data["tags_data"] tags_data = res_data["tags_data"]
@ -157,7 +156,7 @@ class GeneralLedgerXslx(models.AbstractModel):
report_data, report_data,
) )
if not account["partners"]: if "list_grouped" not in account:
# Display array header for move lines # Display array header for move lines
self.write_array_header(report_data) self.write_array_header(report_data)
@ -233,23 +232,23 @@ class GeneralLedgerXslx(models.AbstractModel):
else: else:
# For each partner # For each partner
for partner in account["list_partner"]: for group_item in account["list_grouped"]:
# Write partner title # Write partner title
self.write_array_title( self.write_array_title(group_item["name"], report_data)
partners_data[partner["id"]]["name"], report_data
)
# Display array header for move lines # Display array header for move lines
self.write_array_header(report_data) self.write_array_header(report_data)
# Display initial balance line for partner # Display initial balance line for partner
partner.update( group_item.update(
{ {
"initial_debit": partner["init_bal"]["debit"], "initial_debit": group_item["init_bal"]["debit"],
"initial_credit": partner["init_bal"]["credit"], "initial_credit": group_item["init_bal"]["credit"],
"initial_balance": partner["init_bal"]["balance"], "initial_balance": group_item["init_bal"]["balance"],
"name": partners_data[partner["id"]]["name"],
"type": "partner", "type": "partner",
"grouped_by": account["grouped_by"]
if "grouped_by" in account
else "",
"currency_id": accounts_data[account["id"]]["currency_id"], "currency_id": accounts_data[account["id"]]["currency_id"],
} }
) )
@ -259,11 +258,11 @@ class GeneralLedgerXslx(models.AbstractModel):
"initial_bal_curr": partner["init_bal"]["bal_curr"], "initial_bal_curr": partner["init_bal"]["bal_curr"],
} }
) )
self.write_initial_balance_from_dict(partner, report_data) self.write_initial_balance_from_dict(group_item, report_data)
# Display account move lines # Display account move lines
total_bal_curr = 0 total_bal_curr = 0
for line in partner["move_lines"]: for line in group_item["move_lines"]:
line.update( line.update(
{ {
"account": account["code"], "account": account["code"],
@ -303,22 +302,22 @@ class GeneralLedgerXslx(models.AbstractModel):
self.write_line_from_dict(line, report_data) self.write_line_from_dict(line, report_data)
# Display ending balance line for partner # Display ending balance line for partner
partner.update( group_item.update(
{ {
"final_debit": partner["fin_bal"]["debit"], "final_debit": group_item["fin_bal"]["debit"],
"final_credit": partner["fin_bal"]["credit"], "final_credit": group_item["fin_bal"]["credit"],
"final_balance": partner["fin_bal"]["balance"], "final_balance": group_item["fin_bal"]["balance"],
} }
) )
if foreign_currency and partner["currency_id"]: if foreign_currency and group_item["currency_id"]:
partner.update( group_item.update(
{ {
"final_bal_curr": partner["fin_bal"]["bal_curr"], "final_bal_curr": group_item["fin_bal"]["bal_curr"],
"currency_name": partner["currency_id"].name, "currency_name": group_item["currency_id"].name,
"currency_id": partner["currency_id"].id, "currency_id": group_item["currency_id"].id,
} }
) )
self.write_ending_balance_from_dict(partner, report_data) self.write_ending_balance_from_dict(group_item, report_data)
# Line break # Line break
report_data["row_pos"] += 1 report_data["row_pos"] += 1
@ -346,22 +345,21 @@ class GeneralLedgerXslx(models.AbstractModel):
def write_initial_balance_from_dict(self, my_object, report_data): def write_initial_balance_from_dict(self, my_object, report_data):
"""Specific function to write initial balance for General Ledger""" """Specific function to write initial balance for General Ledger"""
if "partner" in my_object["type"]: label = False
label = _("Partner Initial balance") if "account" not in my_object["type"] and "grouped_by" in my_object:
elif "account" in my_object["type"]: if my_object["grouped_by"] == "partners":
label = _("Initial balance") label = _("Partner Initial balance")
super(GeneralLedgerXslx, self).write_initial_balance_from_dict( label = label if label else _("Initial balance")
my_object, label, report_data super().write_initial_balance_from_dict(my_object, label, report_data)
)
def write_ending_balance_from_dict(self, my_object, report_data): def write_ending_balance_from_dict(self, my_object, report_data):
"""Specific function to write ending balance for General Ledger""" """Specific function to write ending balance for General Ledger"""
if "partner" in my_object["type"]: label = name = False
name = my_object["name"] if "account" in my_object["type"]:
label = _("Partner ending balance")
elif "account" in my_object["type"]:
name = my_object["code"] + " - " + my_object["name"] name = my_object["code"] + " - " + my_object["name"]
label = _("Ending balance") elif "grouped_by" in my_object:
super(GeneralLedgerXslx, self).write_ending_balance_from_dict( name = my_object["name"]
my_object, name, label, report_data if my_object["grouped_by"] == "partners":
) label = _("Partner ending balance")
label = label if label else _("Ending balance")
super().write_ending_balance_from_dict(my_object, name, label, report_data)

View File

@ -35,48 +35,42 @@
<!-- Display account header --> <!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" /> <div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%"> <div class="act_as_caption account_title" style="width: 100%">
<span <span t-esc="account['code']" /> - <span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'code')" t-esc="account['name']"
/>
-
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'name')"
/> />
</div> </div>
<t t-if="not account['partners']"> <t t-if="'list_grouped' not in account">
<!-- Display account move lines without partner regroup --> <!-- Display account move lines without partner regroup -->
<t t-set="type" t-value='"account_type"' /> <t t-set="type" t-value='"account_type"' />
<t <t
t-call="account_financial_report.report_general_ledger_lines" t-call="account_financial_report.report_general_ledger_lines"
> >
<t t-set="account_or_partner_object" t-value="account" /> <t t-set="account_or_group_item_object" t-value="account" />
</t> </t>
<!-- Display account footer --> <!-- Display account footer -->
<t <t
t-call="account_financial_report.report_general_ledger_ending_cumul" t-call="account_financial_report.report_general_ledger_ending_cumul"
> >
<t t-set="account_or_partner_object" t-value="account" /> <t t-set="account_or_group_item_object" t-value="account" />
<t t-set="type" t-value='"account_type"' /> <t t-set="type" t-value='"account_type"' />
</t> </t>
</t> </t>
<t t-if="account['partners']"> <t t-if="'list_grouped' in account">
<!-- Display account partners --> <!-- Display account partners -->
<t t-foreach="account['list_partner']" t-as="partner"> <t t-foreach="account['list_grouped']" t-as="group_item">
<t t-set="type" t-value='"partner_type"' /> <t t-set="type" t-value='"partner_type"' />
<div class="page_break"> <div class="page_break">
<!-- Display partner header --> <!-- Display partner header -->
<div class="act_as_caption account_title"> <div class="act_as_caption account_title">
<span <span t-esc="group_item['name']" />
t-esc="o._get_atr_from_dict(partner['id'], partners_data, 'name')"
/>
</div> </div>
<!-- Display partner move lines --> <!-- Display partner move lines -->
<t <t
t-call="account_financial_report.report_general_ledger_lines" t-call="account_financial_report.report_general_ledger_lines"
> >
<t <t
t-set="account_or_partner_object" t-set="account_or_group_item_object"
t-value="partner" t-value="group_item"
/> />
</t> </t>
<!-- Display partner footer --> <!-- Display partner footer -->
@ -84,8 +78,8 @@
t-call="account_financial_report.report_general_ledger_ending_cumul" t-call="account_financial_report.report_general_ledger_ending_cumul"
> >
<t <t
t-set="account_or_partner_object" t-set="account_or_group_item_object"
t-value="partner" t-value="group_item"
/> />
<t t-set="type" t-value='"partner_type"' /> <t t-set="type" t-value='"partner_type"' />
</t> </t>
@ -97,7 +91,7 @@
t-call="account_financial_report.report_general_ledger_ending_cumul" t-call="account_financial_report.report_general_ledger_ending_cumul"
> >
<t <t
t-set="account_or_partner_object" t-set="account_or_group_item_object"
t-value="account" t-value="account"
/> />
<t t-set="type" t-value='"account_type"' /> <t t-set="type" t-value='"account_type"' />
@ -238,8 +232,8 @@
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
t-raw="account_or_partner_object['init_bal']['debit']" t-raw="account_or_group_item_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
</t> </t>
@ -247,14 +241,14 @@
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', account['id']), t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']), ('partner_id', '=', group_item['id']),
('date', '&lt;', date_from), ('date', '&lt;', date_from),
('debit', '&lt;&gt;', 0)]" ('debit', '&lt;&gt;', 0)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
t-raw="account_or_partner_object['init_bal']['debit']" t-raw="account_or_group_item_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
</t> </t>
@ -270,8 +264,8 @@
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
t-raw="account_or_partner_object['init_bal']['credit']" t-raw="account_or_group_item_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
</t> </t>
@ -279,14 +273,14 @@
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', account['id']), t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']), ('partner_id', '=', group_item['id']),
('date', '&lt;', date_from), ('date', '&lt;', date_from),
('credit', '&lt;&gt;', 0)]" ('credit', '&lt;&gt;', 0)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
t-raw="account_or_partner_object['init_bal']['credit']" t-raw="account_or_group_item_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
</t> </t>
@ -301,8 +295,8 @@
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
t-raw="account_or_partner_object['init_bal']['balance']" t-raw="account_or_group_item_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
</t> </t>
@ -310,21 +304,19 @@
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', account['id']), t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']), ('partner_id', '=', group_item['id']),
('date', '&lt;', date_from)]" ('date', '&lt;', date_from)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
t-raw="account_or_partner_object['init_bal']['balance']" t-raw="account_or_group_item_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
</t> </t>
</div> </div>
<t t-if="foreign_currency"> <t t-if="foreign_currency">
<t <t t-if="account['currency_id']">
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<div class="act_as_cell amount" style="width: 3.63%;"> <div class="act_as_cell amount" style="width: 3.63%;">
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
<t <t
@ -337,8 +329,8 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_partner_object['init_bal']['bal_curr']" t-raw="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}" t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/> />
</span> </span>
</t> </t>
@ -346,7 +338,7 @@
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', account['id']), t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']), ('partner_id', '=', group_item['id']),
('date', '&lt;', o.date_from)]" ('date', '&lt;', o.date_from)]"
/> />
<span <span
@ -354,17 +346,15 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_partner_object['init_bal']['bal_curr']" t-raw="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}" t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/> />
</span> </span>
</t> </t>
</div> </div>
<div class="act_as_cell amount" style="width: 3.63%;" /> <div class="act_as_cell amount" style="width: 3.63%;" />
</t> </t>
<t <t t-if="not account['currency_id']">
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<div class="act_as_cell" style="width: 3.63%;" /> <div class="act_as_cell" style="width: 3.63%;" />
<div class="act_as_cell" style="width: 3.63%;" /> <div class="act_as_cell" style="width: 3.63%;" />
</t> </t>
@ -372,7 +362,7 @@
</div> </div>
<!-- Display each lines --> <!-- Display each lines -->
<t t-set="total_bal_curr" t-value="0" /> <t t-set="total_bal_curr" t-value="0" />
<t t-foreach="account_or_partner_object['move_lines']" t-as="line"> <t t-foreach="account_or_group_item_object['move_lines']" t-as="line">
<!-- # lines or centralized lines --> <!-- # lines or centralized lines -->
<div class="act_as_row lines"> <div class="act_as_row lines">
<!--## date--> <!--## date-->
@ -431,9 +421,7 @@
res-model="account.account" res-model="account.account"
view-type="form" view-type="form"
> >
<t <t t-raw="account['code']" />
t-raw="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/>
</span> </span>
</div> </div>
<!--## taxes--> <!--## taxes-->
@ -637,17 +625,14 @@
<!--## date--> <!--## date-->
<t t-if='type == "account_type"'> <t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;"> <div class="act_as_cell first_column" style="width: 41.32%;">
<span <span t-esc="account['code']" /> - <span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'code')" t-esc="account['name']"
/>
-
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'name')"
/> />
</div> </div>
<div class="act_as_cell right" style="width: 16.9%;"> <div
Ending balance class="act_as_cell right"
</div> style="width: 16.9%;"
>Ending balance</div>
</t> </t>
<t t-if='type == "partner_type"'> <t t-if='type == "partner_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;" /> <div class="act_as_cell first_column" style="width: 41.32%;" />
@ -668,29 +653,27 @@
<!--## debit--> <!--## debit-->
<div class="act_as_cell amount" style="width: 8.02%;"> <div class="act_as_cell amount" style="width: 8.02%;">
<span <span
t-esc="account_or_partner_object['fin_bal']['debit']" t-esc="account_or_group_item_object['fin_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</div> </div>
<!--## credit--> <!--## credit-->
<div class="act_as_cell amount" style="width: 8.02%;"> <div class="act_as_cell amount" style="width: 8.02%;">
<span <span
t-esc="account_or_partner_object['fin_bal']['credit']" t-esc="account_or_group_item_object['fin_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</div> </div>
<!--## balance cumulated--> <!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 8.02%;"> <div class="act_as_cell amount" style="width: 8.02%;">
<span <span
t-esc="account_or_partner_object['fin_bal']['balance']" t-esc="account_or_group_item_object['fin_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</div> </div>
<!--## currency_name + amount_currency--> <!--## currency_name + amount_currency-->
<t t-if="foreign_currency"> <t t-if="foreign_currency">
<t <t t-if="account['currency_id']">
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<div class="act_as_cell amount" style="width: 3.63%;"> <div class="act_as_cell amount" style="width: 3.63%;">
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
<t <t
@ -706,8 +689,8 @@
style="color: black;" style="color: black;"
> >
<t <t
t-raw="account_or_partner_object['fin_bal']['bal_curr']" t-raw="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}" t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/> />
</a> </a>
</span> </span>
@ -716,7 +699,7 @@
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', account['id']), t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']), ('partner_id', '=', group_item['id']),
('date', '&lt;', date_from)]" ('date', '&lt;', date_from)]"
/> />
<span> <span>
@ -727,8 +710,8 @@
style="color: black;" style="color: black;"
> >
<t <t
t-raw="account_or_partner_object['fin_bal']['bal_curr']" t-raw="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}" t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/> />
</a> </a>
</span> </span>
@ -736,9 +719,7 @@
</div> </div>
<div class="act_as_cell amount" style="width: 3.63%;" /> <div class="act_as_cell amount" style="width: 3.63%;" />
</t> </t>
<t <t t-if="not account['currency_id']">
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<div class="act_as_cell amount" style="width: 3.63%;" /> <div class="act_as_cell amount" style="width: 3.63%;" />
<div class="act_as_cell amount" style="width: 3.63%;" /> <div class="act_as_cell amount" style="width: 3.63%;" />
</t> </t>

View File

@ -128,7 +128,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
partner_in_report = False partner_in_report = False
for account in general_ledger: for account in general_ledger:
if account["id"] == account_id and account["partners"]: if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]: for partner in account["list_grouped"]:
if partner["id"] == partner_id: if partner["id"] == partner_id:
partner_in_report = True partner_in_report = True
return partner_in_report return partner_in_report
@ -146,7 +146,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
initial_balance = False initial_balance = False
for account in general_ledger: for account in general_ledger:
if account["id"] == account_id and account["partners"]: if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]: for partner in account["list_grouped"]:
if partner["id"] == partner_id: if partner["id"] == partner_id:
initial_balance = partner["init_bal"] initial_balance = partner["init_bal"]
return initial_balance return initial_balance
@ -164,7 +164,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
final_balance = False final_balance = False
for account in general_ledger: for account in general_ledger:
if account["id"] == account_id and account["partners"]: if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]: for partner in account["list_grouped"]:
if partner["id"] == partner_id: if partner["id"] == partner_id:
final_balance = partner["fin_bal"] final_balance = partner["fin_bal"]
return final_balance return final_balance

View File

@ -83,9 +83,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
string="Account Code To", string="Account Code To",
help="Ending account in a range", help="Ending account in a range",
) )
show_partner_details = fields.Boolean( grouped_by = fields.Selection(
string="Show Partner Details", selection=[("none", "None"), ("partners", "Partners")],
default=True, default="partners",
string="Grouped by",
) )
show_cost_center = fields.Boolean( show_cost_center = fields.Boolean(
string="Show Analytic Account", string="Show Analytic Account",
@ -305,7 +306,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
"company_id": self.company_id.id, "company_id": self.company_id.id,
"account_ids": self.account_ids.ids, "account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids, "partner_ids": self.partner_ids.ids,
"show_partner_details": self.show_partner_details, "grouped_by": self.grouped_by,
"cost_center_ids": self.cost_center_ids.ids, "cost_center_ids": self.cost_center_ids.ids,
"show_cost_center": self.show_cost_center, "show_cost_center": self.show_cost_center,
"analytic_tag_ids": self.analytic_tag_ids.ids, "analytic_tag_ids": self.analytic_tag_ids.ids,

View File

@ -22,11 +22,11 @@
<field name="date_from" /> <field name="date_from" />
<field name="date_to" /> <field name="date_to" />
<field name="fy_start_date" invisible="1" /> <field name="fy_start_date" invisible="1" />
<field name="target_move" widget="radio" />
</group> </group>
<group name="other_filters"> <group name="other_filters">
<field name="target_move" widget="radio" /> <field name="grouped_by" />
<field name="centralize" /> <field name="centralize" />
<field name="show_partner_details" />
<field name="hide_account_at_0" /> <field name="hide_account_at_0" />
<field name="foreign_currency" /> <field name="foreign_currency" />
<field name="show_analytic_tags" /> <field name="show_analytic_tags" />