Browse Source

[IMP] account_financial_report: multiple fixes and improvements

pull/682/head
Jordi Ballester Alomar 5 years ago
committed by Joan Sisquella
parent
commit
d829dfc31a
  1. 956
      account_financial_report/i18n/es.po
  2. 25
      account_financial_report/report/abstract_report_xlsx.py
  3. 64
      account_financial_report/report/aged_partner_balance.py
  4. 2
      account_financial_report/report/aged_partner_balance_xlsx.py
  5. 81
      account_financial_report/report/general_ledger.py
  6. 47
      account_financial_report/report/general_ledger_xlsx.py
  7. 371
      account_financial_report/report/open_items.py
  8. 29
      account_financial_report/report/open_items_xlsx.py
  9. 2
      account_financial_report/report/templates/aged_partner_balance.xml
  10. 21
      account_financial_report/report/templates/general_ledger.xml
  11. 8
      account_financial_report/report/templates/open_items.xml
  12. 76
      account_financial_report/report/trial_balance.py
  13. 16
      account_financial_report/report/vat_report.py
  14. 2
      account_financial_report/wizard/aged_partner_balance_wizard.py
  15. 1
      account_financial_report/wizard/aged_partner_balance_wizard_view.xml
  16. 2
      account_financial_report/wizard/general_ledger_wizard.py
  17. 1
      account_financial_report/wizard/general_ledger_wizard_view.xml

956
account_financial_report/i18n/es.po
File diff suppressed because it is too large
View File

25
account_financial_report/report/abstract_report_xlsx.py

@ -440,25 +440,29 @@ class AbstractReportXslx(models.AbstractModel):
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_header_right
)
elif cell_type == "currency_name":
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_header_right
)
self.row_pos += 1
def _get_currency_amt_format(self, line_object):
""" Return amount format specific for each currency. """
if hasattr(line_object, "account_group_id") and line_object.account_group_id:
format_amt = self.format_amount_bold
if "account_group_id" in line_object and line_object["account_group_id"]:
format_amt = getattr(self, "format_amount_bold")
field_prefix = "format_amount_bold"
else:
format_amt = self.format_amount
format_amt = getattr(self, "format_amount")
field_prefix = "format_amount"
if line_object.currency_id:
field_name = "{}_{}".format(field_prefix, line_object.currency_id.name)
if "currency_id" in line_object and line_object.get("currency_id", False):
field_name = "{}_{}".format(field_prefix, line_object["currency_id"].name)
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
format_amt = self.workbook.add_format()
self.field_name = format_amt
setattr(self, "field_name", format_amt)
format_amount = "#,##0." + (
"0" * line_object.currency_id.decimal_places
"0" * line_object["currency_id"].decimal_places
)
format_amt.set_num_format(format_amount)
return format_amt
@ -469,10 +473,13 @@ class AbstractReportXslx(models.AbstractModel):
format_amt = self.format_amount_bold
field_prefix = "format_amount_bold"
else:
format_amt = self.format_amount
format_amt = getattr(self, "format_amount")
field_prefix = "format_amount"
if line_dict.get("currency_id", False) and line_dict["currency_id"]:
currency = self.env["res.currency"].browse([line_dict["currency_id"]])
if isinstance(line_dict["currency_id"], int):
currency = self.env["res.currency"].browse(line_dict["currency_id"])
else:
currency = line_dict["currency_id"]
field_name = "{}_{}".format(field_prefix, currency.name)
if hasattr(self, field_name):
format_amt = getattr(self, field_name)

64
account_financial_report/report/aged_partner_balance.py

@ -2,6 +2,7 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import operator
from datetime import date, datetime, timedelta
from odoo import api, models
@ -63,7 +64,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
@api.model
def _get_move_lines_domain(
self, company_id, account_ids, partner_ids, only_posted_moves
self, company_id, account_ids, partner_ids, only_posted_moves, date_from
):
domain = [
("account_id", "in", account_ids),
@ -74,6 +75,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
if date_from:
domain += [("date", ">", date_from)]
return domain
@api.model
@ -104,7 +107,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
return ag_pb_data
def _get_account_partial_reconciled(self, company_id, date_at_object):
domain = [("max_date", ">=", date_at_object), ("company_id", "=", company_id)]
domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)]
fields = ["debit_move_id", "credit_move_id", "amount"]
accounts_partial_reconcile = self.env["account.partial.reconcile"].search_read(
domain=domain, fields=fields
@ -153,11 +156,14 @@ class AgedPartnerBalanceReport(models.AbstractModel):
partner_ids,
only_posted_moves,
):
reconciled_ids = list(debit_ids) + list(credit_ids)
new_ml_ids = []
for reconciled_id in reconciled_ids:
if reconciled_id not in ml_ids and reconciled_id not in new_ml_ids:
new_ml_ids += [reconciled_id]
debit_ids = set(debit_ids)
credit_ids = set(credit_ids)
in_credit_but_not_in_debit = credit_ids - debit_ids
reconciled_ids = list(debit_ids) + list(in_credit_but_not_in_debit)
reconciled_ids = set(reconciled_ids)
ml_ids = set(ml_ids)
new_ml_ids = reconciled_ids - ml_ids
new_ml_ids = list(new_ml_ids)
new_domain = self._get_new_move_lines_domain(
new_ml_ids, account_ids, company_id, partner_ids, only_posted_moves
)
@ -192,11 +198,12 @@ class AgedPartnerBalanceReport(models.AbstractModel):
account_ids,
partner_ids,
date_at_object,
date_from,
only_posted_moves,
show_move_line_details,
):
domain = self._get_move_lines_domain(
company_id, account_ids, partner_ids, only_posted_moves
company_id, account_ids, partner_ids, only_posted_moves, date_from
)
ml_fields = [
"id",
@ -225,9 +232,13 @@ class AgedPartnerBalanceReport(models.AbstractModel):
credit_amount,
) = self._get_account_partial_reconciled(company_id, date_at_object)
if acc_partial_rec:
ml_ids = map(lambda r: r["id"], move_lines)
debit_ids = map(lambda r: r["debit_move_id"], acc_partial_rec)
credit_ids = map(lambda r: r["credit_move_id"], acc_partial_rec)
ml_ids = list(map(operator.itemgetter("id"), move_lines))
debit_ids = list(
map(operator.itemgetter("debit_move_id"), acc_partial_rec)
)
credit_ids = list(
map(operator.itemgetter("credit_move_id"), acc_partial_rec)
)
move_lines = self._recalculate_move_lines(
move_lines,
debit_ids,
@ -240,15 +251,12 @@ class AgedPartnerBalanceReport(models.AbstractModel):
partner_ids,
only_posted_moves,
)
moves_lines_to_remove = []
for move_line in move_lines:
if move_line["date"] > date_at_object or float_is_zero(
move_line["amount_residual"], precision_digits=2
):
moves_lines_to_remove.append(move_line)
if len(moves_lines_to_remove) > 0:
for move_line_to_remove in moves_lines_to_remove:
move_lines.remove(move_line_to_remove)
move_lines = [
move_line
for move_line in move_lines
if move_line["date"] <= date_at_object
and not float_is_zero(move_line["amount_residual"], precision_digits=2)
]
for move_line in move_lines:
journals_ids.add(move_line["journal_id"][0])
acc_id = move_line["account_id"][0]
@ -267,6 +275,17 @@ class AgedPartnerBalanceReport(models.AbstractModel):
ag_pb_data = self._initialize_partner(ag_pb_data, acc_id, prt_id)
move_line_data = {}
if show_move_line_details:
if move_line["ref"] == move_line["name"]:
if move_line["ref"]:
ref_label = move_line["ref"]
else:
ref_label = ""
elif not move_line["ref"]:
ref_label = move_line["name"]
elif not move_line["name"]:
ref_label = move_line["ref"]
else:
ref_label = move_line["ref"] + str(" - ") + move_line["name"]
move_line_data.update(
{
"date": move_line["date"],
@ -274,7 +293,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
"jnl_id": move_line["journal_id"][0],
"acc_id": acc_id,
"partner": prt_name,
"ref": move_line["ref"],
"ref_label": ref_label,
"due_date": move_line["date_maturity"],
"residual": move_line["amount_residual"],
}
@ -420,7 +439,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
partner_ids = data["partner_ids"]
date_at = data["date_at"]
date_at_object = datetime.strptime(date_at, "%Y-%m-%d").date()
date_from = data["date_from"]
only_posted_moves = data["only_posted_moves"]
show_move_line_details = data["show_move_line_details"]
(
@ -433,6 +452,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
account_ids,
partner_ids,
date_at_object,
date_from,
only_posted_moves,
show_move_line_details,
)

2
account_financial_report/report/aged_partner_balance_xlsx.py

@ -85,7 +85,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
2: {"header": _("Journal"), "field": "journal", "width": 8},
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Partner"), "field": "partner", "width": 25},
5: {"header": _("Ref - Label"), "field": "ref", "width": 40},
5: {"header": _("Ref - Label"), "field": "ref_label", "width": 40},
6: {"header": _("Due date"), "field": "due_date", "width": 11},
7: {
"header": _("Residual"),

81
account_financial_report/report/general_ledger.py

@ -4,6 +4,7 @@
import calendar
import datetime
import operator
from odoo import api, models
@ -55,6 +56,7 @@ class GeneralLedgerReport(models.AbstractModel):
"id": tax.id,
"amount": tax.amount,
"amount_type": tax.amount_type,
"display_name": tax.display_name,
}
}
)
@ -62,6 +64,13 @@ class GeneralLedgerReport(models.AbstractModel):
taxes_data[tax.id]["string"] = "%"
else:
taxes_data[tax.id]["string"] = ""
taxes_data[tax.id]["tax_name"] = (
tax.display_name
+ " ("
+ str(tax.amount)
+ taxes_data[tax.id]["string"]
+ ")"
)
return taxes_data
def _get_acc_prt_accounts_ids(self, company_id):
@ -301,6 +310,7 @@ class GeneralLedgerReport(models.AbstractModel):
if move_line["partner_id"]
else "",
"ref": "" if not move_line["ref"] else move_line["ref"],
"name": "" if not move_line["name"] else move_line["name"],
"tax_ids": move_line["tax_ids"],
"debit": move_line["debit"],
"credit": move_line["credit"],
@ -315,6 +325,16 @@ class GeneralLedgerReport(models.AbstractModel):
"tag_ids": move_line["analytic_tag_ids"],
"currency_id": move_line["currency_id"],
}
if (
move_line_data["ref"] == move_line_data["name"]
or move_line_data["ref"] == ""
):
ref_label = move_line_data["name"]
elif move_line_data["name"] == "":
ref_label = move_line_data["ref"]
else:
ref_label = move_line_data["ref"] + str(" - ") + move_line_data["name"]
move_line_data.update({"ref_label": ref_label})
return move_line_data
@api.model
@ -383,6 +403,22 @@ class GeneralLedgerReport(models.AbstractModel):
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):
full_reconcile_ids = list(full_reconcile_ids)
domain = [
("max_date", ">", date_to),
("full_reconcile_id", "in", full_reconcile_ids),
]
fields = ["full_reconcile_id"]
reconciled_after_date_to = self.env["account.partial.reconcile"].search_read(
domain=domain, fields=fields
)
rec_after_date_to_ids = list(
map(operator.itemgetter("full_reconcile_id"), reconciled_after_date_to)
)
rec_after_date_to_ids = [i[0] for i in rec_after_date_to_ids]
return rec_after_date_to_ids
def _get_period_ml_data(
self,
account_ids,
@ -427,6 +463,7 @@ class GeneralLedgerReport(models.AbstractModel):
"analytic_tag_ids",
"amount_currency",
"ref",
"name",
]
move_lines = self.env["account.move.line"].search_read(
domain=domain, fields=ml_fields
@ -497,6 +534,9 @@ class GeneralLedgerReport(models.AbstractModel):
accounts_data = self._get_accounts_data(gen_ld_data.keys())
taxes_data = self._get_taxes_data(list(taxes_ids))
tags_data = self._get_tags_data(list(tags_ids))
rec_after_date_to_ids = self._get_reconciled_after_date_to_ids(
full_reconcile_data.keys(), date_to
)
return (
gen_ld_data,
accounts_data,
@ -505,17 +545,24 @@ class GeneralLedgerReport(models.AbstractModel):
full_reconcile_data,
taxes_data,
tags_data,
rec_after_date_to_ids,
)
@api.model
def _recalculate_cumul_balance(self, move_lines, last_cumul_balance):
def _recalculate_cumul_balance(
self, move_lines, last_cumul_balance, rec_after_date_to_ids
):
for move_line in move_lines:
move_line["balance"] += last_cumul_balance
last_cumul_balance = move_line["balance"]
if move_line["rec_id"] in rec_after_date_to_ids:
move_line["rec_name"] = str("*") + move_line["rec_name"]
return move_lines
@api.model
def _create_general_ledger(self, gen_led_data, accounts_data):
def _create_general_ledger(
self, gen_led_data, accounts_data, show_partner_details, rec_after_date_to_ids
):
general_ledger = []
for acc_id in gen_led_data.keys():
account = {}
@ -537,10 +584,13 @@ class GeneralLedgerReport(models.AbstractModel):
move_lines += [gen_led_data[acc_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]["init_bal"]["balance"]
move_lines,
gen_led_data[acc_id]["init_bal"]["balance"],
rec_after_date_to_ids,
)
account.update({"move_lines": move_lines})
else:
if show_partner_details:
list_partner = []
for prt_id in gen_led_data[acc_id].keys():
partner = {}
@ -559,10 +609,27 @@ class GeneralLedgerReport(models.AbstractModel):
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})
list_partner += [partner]
account.update({"list_partner": list_partner})
else:
move_lines = []
for prt_id in gen_led_data[acc_id].keys():
if not isinstance(prt_id, int):
account.update({prt_id: gen_led_data[acc_id][prt_id]})
else:
for ml_id in gen_led_data[acc_id][prt_id].keys():
if isinstance(ml_id, int):
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]["init_bal"]["balance"],
rec_after_date_to_ids,
)
account.update({"move_lines": move_lines, "partners": False})
general_ledger += [account]
return general_ledger
@ -581,7 +648,7 @@ class GeneralLedgerReport(models.AbstractModel):
centralized_ml[jnl_id][month].update(
{
"journal_id": jnl_id,
"ref": "Centralized entries",
"ref_label": "Centralized entries",
"date": date,
"debit": 0.0,
"credit": 0.0,
@ -640,6 +707,7 @@ class GeneralLedgerReport(models.AbstractModel):
account_ids = data["account_ids"]
analytic_tag_ids = data["analytic_tag_ids"]
cost_center_ids = data["cost_center_ids"]
show_partner_details = data["show_partner_details"]
hide_account_at_0 = data["hide_account_at_0"]
foreign_currency = data["foreign_currency"]
only_posted_moves = data["only_posted_moves"]
@ -667,6 +735,7 @@ class GeneralLedgerReport(models.AbstractModel):
full_reconcile_data,
taxes_data,
tags_data,
rec_after_date_to_ids,
) = self._get_period_ml_data(
account_ids,
partner_ids,
@ -683,7 +752,9 @@ class GeneralLedgerReport(models.AbstractModel):
analytic_tag_ids,
cost_center_ids,
)
general_ledger = self._create_general_ledger(gen_ld_data, accounts_data)
general_ledger = self._create_general_ledger(
gen_ld_data, accounts_data, show_partner_details, rec_after_date_to_ids
)
if centralize:
for account in general_ledger:
if account["centralized"]:

47
account_financial_report/report/general_ledger_xlsx.py

@ -28,7 +28,7 @@ class GeneralLedgerXslx(models.AbstractModel):
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Taxes"), "field": "taxes_description", "width": 15},
5: {"header": _("Partner"), "field": "partner_name", "width": 25},
6: {"header": _("Ref - Label"), "field": "ref", "width": 40},
6: {"header": _("Ref - Label"), "field": "ref_label", "width": 40},
7: {"header": _("Cost center"), "field": "cost_center", "width": 15},
8: {"header": _("Tags"), "field": "tags", "width": 10},
9: {"header": _("Rec."), "field": "rec_name", "width": 5},
@ -173,20 +173,15 @@ class GeneralLedgerXslx(models.AbstractModel):
"currency_id": line["currency_id"][0],
}
)
if line["ref"] != "Centralized entries":
if line["ref_label"] != "Centralized entries":
taxes_description = ""
tags = ""
for tax_id in line["tax_ids"]:
taxes_description += (
str(taxes_data[tax_id]["amount"])
+ " "
+ taxes_data[tax_id]["string"]
+ " "
)
taxes_description += taxes_data[tax_id]["tax_name"] + " "
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
line.update(
{"taxes_description": taxes_description, "tags": tags}
{"taxes_description": taxes_description, "tags": tags,}
)
self.write_line_from_dict(line)
# Display ending balance line for account
@ -225,7 +220,7 @@ class GeneralLedgerXslx(models.AbstractModel):
)
if foreign_currency:
partner.update(
{"initial_bal_culrr": partner["init_bal"]["bal_curr"]}
{"initial_bal_curr": partner["init_bal"]["bal_curr"],}
)
self.write_initial_balance_from_dict(partner)
@ -237,20 +232,24 @@ class GeneralLedgerXslx(models.AbstractModel):
"journal": journals_data[line["journal_id"]]["code"],
}
)
if line["ref"] != "Centralized entries":
if line["currency_id"]:
line.update(
{
"currency_name": line["currency_id"][1],
"currency_id": line["currency_id"][0],
}
)
if line["ref_label"] != "Centralized entries":
taxes_description = ""
tags = ""
for tax_id in line["tax_ids"]:
taxes_description += (
str(taxes_data[tax_id]["amount"])
+ " "
+ taxes_data[tax_id]["string"]
+ " "
taxes_data[tax_id]["tax_name"] + " "
)
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
line.update(
{"taxes_description": taxes_description, "tags": tags}
{"taxes_description": taxes_description, "tags": tags,}
)
self.write_line_from_dict(line)
@ -262,9 +261,13 @@ class GeneralLedgerXslx(models.AbstractModel):
"final_balance": partner["fin_bal"]["balance"],
}
)
if foreign_currency:
if foreign_currency and partner["currency_id"]:
partner.update(
{"final_bal_curr": partner["fin_bal"]["bal_curr"]}
{
"final_bal_curr": partner["fin_bal"]["bal_curr"],
"currency_name": partner["currency_id"].name,
"currency_id": partner["currency_id"].id,
}
)
self.write_ending_balance_from_dict(partner)
@ -279,9 +282,13 @@ class GeneralLedgerXslx(models.AbstractModel):
"final_balance": account["fin_bal"]["balance"],
}
)
if foreign_currency:
if foreign_currency and account["currency_id"]:
account.update(
{"final_bal_curr": account["fin_bal"]["bal_curr"],}
{
"final_bal_curr": account["fin_bal"]["bal_curr"],
"currency_name": account["currency_id"].name,
"currency_id": account["currency_id"].id,
}
)
self.write_ending_balance_from_dict(account)

371
account_financial_report/report/open_items.py

@ -6,7 +6,6 @@ import operator
from datetime import date, datetime
from odoo import api, models
from odoo.osv import expression
from odoo.tools import float_is_zero
@ -31,137 +30,113 @@ class OpenItemsReport(models.AbstractModel):
).render(rcontext)
return result
def _get_account_partial_reconciled(self, move_lines_data, date_at_object):
reconciled_ids = []
for move_line in move_lines_data:
if move_line["reconciled"]:
reconciled_ids += [move_line["id"]]
domain = [("max_date", ">=", date_at_object)]
domain += expression.OR(
[
[("debit_move_id", "in", reconciled_ids)],
[("credit_move_id", "in", reconciled_ids)],
]
)
def _get_account_partial_reconciled(self, company_id, date_at_object):
domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)]
fields = ["debit_move_id", "credit_move_id", "amount"]
accounts_partial_reconcile = self.env["account.partial.reconcile"].search_read(
domain=domain, fields=fields
)
debit_accounts_partial_amount = {}
credit_accounts_partial_amount = {}
debit_amount = {}
credit_amount = {}
for account_partial_reconcile_data in accounts_partial_reconcile:
debit_move_id = account_partial_reconcile_data["debit_move_id"][0]
credit_move_id = account_partial_reconcile_data["credit_move_id"][0]
if debit_move_id not in debit_accounts_partial_amount.keys():
debit_accounts_partial_amount[debit_move_id] = 0.0
debit_accounts_partial_amount[
debit_move_id
] += account_partial_reconcile_data["amount"]
if credit_move_id not in credit_accounts_partial_amount.keys():
credit_accounts_partial_amount[credit_move_id] = 0.0
credit_accounts_partial_amount[
credit_move_id
] += account_partial_reconcile_data["amount"]
if debit_move_id not in debit_amount.keys():
debit_amount[debit_move_id] = 0.0
debit_amount[debit_move_id] += account_partial_reconcile_data["amount"]
if credit_move_id not in credit_amount.keys():
credit_amount[credit_move_id] = 0.0
credit_amount[credit_move_id] += account_partial_reconcile_data["amount"]
account_partial_reconcile_data.update(
{"debit_move_id": debit_move_id, "credit_move_id": credit_move_id}
)
return (
accounts_partial_reconcile,
debit_accounts_partial_amount,
credit_accounts_partial_amount,
)
return accounts_partial_reconcile, debit_amount, credit_amount
@api.model
def _get_query_domain(
self,
account_ids,
partner_ids,
date_at_object,
target_move,
company_id,
date_from,
def _get_new_move_lines_domain(
self, new_ml_ids, account_ids, company_id, partner_ids, target_moves
):
query = """
WHERE aml.account_id in %s and aml.company_id = %s
""" % (
tuple(account_ids) if len(account_ids) > 1 else "(%s)" % account_ids[0],
company_id,
)
if date_from:
query += " and aml.date >= '%s'" % date_from
domain = [
("account_id", "in", account_ids),
("company_id", "=", company_id),
("id", "in", new_ml_ids),
]
if partner_ids:
query += " and aml.partner_id in {}".format(tuple(partner_ids))
if target_move == "posted":
query += " and am.state = 'posted'"
if date_at_object >= date.today():
query += " and aml.reconciled IS FALSE"
else:
query += (
""" and ((aml.reconciled IS FALSE OR aml.date >= '%s')
OR aml.full_reconcile_id IS NOT NULL)"""
% date_at_object
)
return query
domain += [("partner_id", "in", partner_ids)]
if target_moves == "posted":
domain += [("move_id.state", "=", "posted")]
return domain
@api.model
def _get_query(
def _recalculate_move_lines(
self,
move_lines,
debit_ids,
credit_ids,
debit_amount,
credit_amount,
ml_ids,
account_ids,
partner_ids,
date_at_object,
target_move,
company_id,
date_from,
partner_ids,
target_moves,
):
aml_fields = [
debit_ids = set(debit_ids)
credit_ids = set(credit_ids)
in_credit_but_not_in_debit = credit_ids - debit_ids
reconciled_ids = list(debit_ids) + list(in_credit_but_not_in_debit)
reconciled_ids = set(reconciled_ids)
ml_ids = set(ml_ids)
new_ml_ids = reconciled_ids - ml_ids
new_ml_ids = list(new_ml_ids)
new_domain = self._get_new_move_lines_domain(
new_ml_ids, account_ids, company_id, partner_ids, target_moves
)
ml_fields = [
"id",
"name",
"date",
"move_id",
"journal_id",
"account_id",
"partner_id",
"ref",
"date_maturity",
"amount_residual",
"amount_currency",
"amount_residual_currency",
"date_maturity",
"ref",
"debit",
"credit",
"currency_id",
"reconciled",
"full_reconcile_id",
"currency_id",
"amount_currency",
"amount_residual_currency",
]
query = ""
# SELECT
for field in aml_fields:
if not query:
query = "SELECT aml.%s" % field
else:
query += ", aml.%s" % field
# name from res_partner
query += ", rp.name as partner_name"
# name from res_currency
query += ", rc.name as currency_name"
# state and name from account_move
query += ", am.state, am.name as move_name"
# FROM
query += """
FROM account_move_line as aml
LEFT JOIN res_partner as rp
ON aml.partner_id = rp.id
LEFT JOIN res_currency as rc
ON aml.currency_id = rc.id
LEFT JOIN account_move as am
ON am.id = aml.move_id
"""
# WHERE
query += self._get_query_domain(
account_ids, partner_ids, date_at_object, target_move, company_id, date_from
new_move_lines = self.env["account.move.line"].search_read(
domain=new_domain, fields=ml_fields
)
return query
move_lines = move_lines + new_move_lines
for move_line in move_lines:
ml_id = move_line["id"]
if ml_id in debit_ids:
move_line["amount_residual"] += debit_amount[ml_id]
if ml_id in credit_ids:
move_line["amount_residual"] -= credit_amount[ml_id]
return move_lines
@api.model
def _get_move_lines_domain(
self, company_id, account_ids, partner_ids, target_move, date_from
):
domain = [
("account_id", "in", account_ids),
("company_id", "=", company_id),
("reconciled", "=", False),
]
if partner_ids:
domain += [("partner_id", "in", partner_ids)]
if target_move == "posted":
domain += [("move_id.state", "=", "posted")]
if date_from:
domain += [("date", ">", date_from)]
return domain
def _get_accounts_data(self, accounts_ids):
accounts = self.env["account.account"].browse(accounts_ids)
@ -188,7 +163,6 @@ class OpenItemsReport(models.AbstractModel):
journals_data.update({journal.id: {"id": journal.id, "code": journal.code}})
return journals_data
# flake8: noqa: C901
def _get_data(
self,
account_ids,
@ -198,69 +172,80 @@ class OpenItemsReport(models.AbstractModel):
company_id,
date_from,
):
query = self._get_query(
account_ids, partner_ids, date_at_object, target_move, company_id, date_from
domain = self._get_move_lines_domain(
company_id, account_ids, partner_ids, target_move, date_from
)
self._cr.execute(query)
move_lines_data = self._cr.dictfetchall()
account_ids = map(lambda r: r["account_id"], move_lines_data)
accounts_data = self._get_accounts_data(list(account_ids))
journal_ids = map(lambda r: r["journal_id"], move_lines_data)
journals_data = self._get_journals_data(list(journal_ids))
ml_fields = [
"id",
"name",
"date",
"move_id",
"journal_id",
"account_id",
"partner_id",
"amount_residual",
"date_maturity",
"ref",
"debit",
"credit",
"reconciled",
"currency_id",
"amount_currency",
"amount_residual_currency",
]
move_lines = self.env["account.move.line"].search_read(
domain=domain, fields=ml_fields
)
journals_ids = set()
partners_ids = set()
partners_data = {}
if date_at_object < date.today():
(
accounts_partial_reconcile,
debit_accounts_partial_amount,
credit_accounts_partial_amount,
) = self._get_account_partial_reconciled(move_lines_data, date_at_object)
if accounts_partial_reconcile:
debit_ids = map(
operator.itemgetter("debit_move_id"), accounts_partial_reconcile
acc_partial_rec,
debit_amount,
credit_amount,
) = self._get_account_partial_reconciled(company_id, date_at_object)
if acc_partial_rec:
ml_ids = list(map(operator.itemgetter("id"), move_lines))
debit_ids = list(
map(operator.itemgetter("debit_move_id"), acc_partial_rec)
)
credit_ids = map(
operator.itemgetter("credit_move_id"), accounts_partial_reconcile
credit_ids = list(
map(operator.itemgetter("credit_move_id"), acc_partial_rec)
)
for move_line in move_lines_data:
if move_line["id"] in debit_ids:
move_line["amount_residual"] += debit_accounts_partial_amount[
move_line["id"]
]
if move_line["id"] in credit_ids:
move_line["amount_residual"] -= credit_accounts_partial_amount[
move_line["id"]
move_lines = self._recalculate_move_lines(
move_lines,
debit_ids,
credit_ids,
debit_amount,
credit_amount,
ml_ids,
account_ids,
company_id,
partner_ids,
target_move,
)
move_lines = [
move_line
for move_line in move_lines
if move_line["date"] <= date_at_object
and not float_is_zero(move_line["amount_residual"], precision_digits=2)
]
moves_lines_to_remove = []
for move_line in move_lines_data:
if move_line["date"] > date_at_object or float_is_zero(
move_line["amount_residual"], precision_digits=2
):
moves_lines_to_remove.append(move_line)
if len(moves_lines_to_remove) > 0:
for move_line_to_remove in moves_lines_to_remove:
move_lines_data.remove(move_line_to_remove)
partners_data = {0: {"id": 0, "name": "Missing Partner"}}
open_items_move_lines_data = {}
for move_line in move_lines_data:
no_partner = True
for move_line in move_lines:
journals_ids.add(move_line["journal_id"][0])
acc_id = move_line["account_id"][0]
# Partners data
if move_line["partner_id"]:
no_partner = False
partners_data.update(
{
move_line["partner_id"]: {
"id": move_line["partner_id"],
"name": move_line["partner_name"],
"currency_id": accounts_data[move_line["account_id"]][
"currency_id"
],
}
}
)
prt_id = move_line["partner_id"][0]
prt_name = move_line["partner_id"][1]
else:
partners_data[0]["currency_id"] = accounts_data[
move_line["account_id"]
]["currency_id"]
prt_id = 0
prt_name = "Missing Partner"
if prt_id not in partners_ids:
partners_data.update({prt_id: {"id": prt_id, "name": prt_name}})
partners_ids.add(prt_id)
# Move line update
original = 0
@ -269,39 +254,51 @@ class OpenItemsReport(models.AbstractModel):
original = move_line["credit"] * (-1)
if not float_is_zero(move_line["debit"], precision_digits=2):
original = move_line["debit"]
if move_line["ref"] == move_line["name"]:
if move_line["ref"]:
ref_label = move_line["ref"]
else:
ref_label = ""
elif not move_line["ref"]:
ref_label = move_line["name"]
elif not move_line["name"]:
ref_label = move_line["ref"]
else:
ref_label = move_line["ref"] + str(" - ") + move_line["name"]
move_line.update(
{
"date": move_line["date"].strftime("%d/%m/%Y"),
"date": move_line["date"],
"date_maturity": move_line["date_maturity"]
and move_line["date_maturity"].strftime("%d/%m/%Y"),
"original": original,
"partner_id": 0 if no_partner else move_line["partner_id"],
"partner_name": "" if no_partner else move_line["partner_name"],
"ref": "" if not move_line["ref"] else move_line["ref"],
"account": accounts_data[move_line["account_id"]]["code"],
"journal": journals_data[move_line["journal_id"]]["code"],
"partner_id": prt_id,
"partner_name": prt_name,
"ref_label": ref_label,
"journal_id": move_line["journal_id"][0],
"move_name": move_line["move_id"][1],
"currency_id": move_line["currency_id"][0]
if move_line["currency_id"]
else False,
"currency_name": move_line["currency_id"][1]
if move_line["currency_id"]
else False,
}
)
# Open Items Move Lines Data
if move_line["account_id"] not in open_items_move_lines_data.keys():
open_items_move_lines_data[move_line["account_id"]] = {
move_line["partner_id"]: [move_line]
}
if acc_id not in open_items_move_lines_data.keys():
open_items_move_lines_data[acc_id] = {prt_id: [move_line]}
else:
if (
move_line["partner_id"]
not in open_items_move_lines_data[move_line["account_id"]].keys()
):
open_items_move_lines_data[move_line["account_id"]][
move_line["partner_id"]
] = [move_line]
if prt_id not in open_items_move_lines_data[acc_id].keys():
open_items_move_lines_data[acc_id][prt_id] = [move_line]
else:
open_items_move_lines_data[move_line["account_id"]][
move_line["partner_id"]
].append(move_line)
open_items_move_lines_data[acc_id][prt_id].append(move_line)
journals_data = self._get_journals_data(list(journals_ids))
accounts_data = self._get_accounts_data(open_items_move_lines_data.keys())
return (
move_lines_data,
move_lines,
partners_data,
journals_data,
accounts_data,
@ -325,8 +322,11 @@ class OpenItemsReport(models.AbstractModel):
return total_amount
@api.model
def _get_open_items_no_partners(self, open_items_move_lines_data):
def _order_open_items_by_date(
self, open_items_move_lines_data, show_partner_details
):
new_open_items = {}
if not show_partner_details:
for acc_id in open_items_move_lines_data.keys():
new_open_items[acc_id] = {}
move_lines = []
@ -335,9 +335,18 @@ class OpenItemsReport(models.AbstractModel):
move_lines += [move_line]
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
new_open_items[acc_id] = move_lines
else:
for acc_id in open_items_move_lines_data.keys():
new_open_items[acc_id] = {}
for prt_id in open_items_move_lines_data[acc_id]:
new_open_items[acc_id][prt_id] = {}
move_lines = []
for move_line in open_items_move_lines_data[acc_id][prt_id]:
move_lines += [move_line]
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
new_open_items[acc_id][prt_id] = move_lines
return new_open_items
@api.multi
def _get_report_values(self, docids, data):
wizard_id = data["wizard_id"]
company = self.env["res.company"].browse(data["company_id"])
@ -361,9 +370,8 @@ class OpenItemsReport(models.AbstractModel):
)
total_amount = self._calculate_amounts(open_items_move_lines_data)
if not show_partner_details:
open_items_move_lines_data = self._get_open_items_no_partners(
open_items_move_lines_data
open_items_move_lines_data = self._order_open_items_by_date(
open_items_move_lines_data, show_partner_details
)
return {
"doc_ids": [wizard_id],
@ -376,6 +384,7 @@ class OpenItemsReport(models.AbstractModel):
"date_at": date_at_object.strftime("%d/%m/%Y"),
"hide_account_at_0": data["hide_account_at_0"],
"target_move": data["target_move"],
"journals_data": journals_data,
"partners_data": partners_data,
"accounts_data": accounts_data,
"total_amount": total_amount,

29
account_financial_report/report/open_items_xlsx.py

@ -22,11 +22,11 @@ class OpenItemsXslx(models.AbstractModel):
def _get_report_columns(self, report):
res = {
0: {"header": _("Date"), "field": "date", "width": 11},
1: {"header": _("Entry"), "field": "move_id_name", "width": 18},
1: {"header": _("Entry"), "field": "move_name", "width": 18},
2: {"header": _("Journal"), "field": "journal", "width": 8},
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Partner"), "field": "partner", "width": 25},
5: {"header": _("Ref - Label"), "field": "ref", "width": 40},
4: {"header": _("Partner"), "field": "partner_name", "width": 25},
5: {"header": _("Ref - Label"), "field": "ref_label", "width": 40},
6: {"header": _("Due date"), "field": "date_maturity", "width": 11},
7: {
"header": _("Original"),
@ -108,6 +108,7 @@ class OpenItemsXslx(models.AbstractModel):
Open_items = res_data["Open_Items"]
accounts_data = res_data["accounts_data"]
partners_data = res_data["partners_data"]
journals_data = res_data["journals_data"]
total_amount = res_data["total_amount"]
show_partner_details = res_data["show_partner_details"]
for account_id in Open_items.keys():
@ -131,9 +132,25 @@ class OpenItemsXslx(models.AbstractModel):
# Display account move lines
for line in Open_items[account_id][partner_id]:
line.update(
{
"account": accounts_data[account_id]["code"],
"journal": journals_data[line["journal_id"]][
"code"
],
}
)
self.write_line_from_dict(line)
# Display ending balance line for partner
partners_data[partner_id].update(
{
"currency_id": accounts_data[account_id]["currency_id"],
"currency_name": accounts_data[account_id][
"currency_name"
],
}
)
self.write_ending_balance_from_dict(
partners_data[partner_id],
type_object,
@ -150,6 +167,12 @@ class OpenItemsXslx(models.AbstractModel):
# Display account move lines
for line in Open_items[account_id]:
line.update(
{
"account": accounts_data[account_id]["code"],
"journal": journals_data[line["journal_id"]]["code"],
}
)
self.write_line_from_dict(line)
# Display ending balance line for account

2
account_financial_report/report/templates/aged_partner_balance.xml

@ -295,7 +295,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<t t-raw="line['ref']" />
<t t-raw="line['ref_label']" />
<!-- </a>-->
<!-- </span>-->
</div>

21
account_financial_report/report/templates/general_ledger.xml

@ -357,7 +357,7 @@
>
<div class="act_as_cell amount" style="width: 2.08%;">
<span
t-field="o._get_atr_from_dict(account['id'], accounts_data, 'currency_name')"
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'currency_name')"
/>
</div>
<div class="act_as_cell amount" style="width: 5.19%;">
@ -376,7 +376,7 @@
>
<t
t-raw="account_or_partner_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
/>
</a>
</span>
@ -397,7 +397,7 @@
>
<t
t-raw="account_or_partner_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
/>
</a>
</span>
@ -501,10 +501,7 @@
<t t-if="taxes_data and line['tax_ids']">
<t t-foreach="line['tax_ids']" t-as="tax_id">
<span
t-esc="o._get_atr_from_dict(tax_id, taxes_data, 'amount')"
/>
<span
t-esc="o._get_atr_from_dict(tax_id, taxes_data, 'string')"
t-esc="o._get_atr_from_dict(tax_id, taxes_data, 'tax_name')"
/>
</t>
</t>
@ -534,7 +531,7 @@
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['ref']" />
<t t-raw="line['ref_label']" />
</a>
</span>
</t>
@ -544,7 +541,7 @@
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['ref']" />
<t t-raw="line['ref_label']" />
</a>
</span>
</t>
@ -780,7 +777,7 @@
>
<div class="act_as_cell amount" style="width: 2.08%;">
<span
t-field="o._get_atr_from_dict(account['id'], accounts_data, 'currency_name')"
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'currency_name')"
/>
</div>
<div class="act_as_cell amount" style="width: 5.19%;">
@ -799,7 +796,7 @@
>
<t
t-raw="account_or_partner_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.account_id.currency_id}"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
/>
</a>
</span>
@ -820,7 +817,7 @@
>
<t
t-raw="account_or_partner_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.report_account_id.currency_id}"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
/>
</a>
</span>

8
account_financial_report/report/templates/open_items.xml

@ -172,7 +172,7 @@
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<span t-raw="line['date']" />
<span t-raw="line['date'].strftime('%d/%m/%Y')" />
</div>
<!--## move-->
<div class="act_as_cell left">
@ -190,11 +190,11 @@
</div>
<!--## journal-->
<div class="act_as_cell left">
<span t-esc="line['journal']" />
<span t-esc="journals_data[line['journal_id']]['code']" />
</div>
<!--## account code-->
<div class="act_as_cell left">
<span t-esc="line['account']" />
<span t-esc="accounts_data[account_id]['code']" />
</div>
<!--## partner-->
<div class="act_as_cell left">
@ -203,7 +203,7 @@
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<span t-esc="line['ref']" />
<span t-esc="line['ref_label']" />
</div>
<!--## date_due-->
<div class="act_as_cell left">

76
account_financial_report/report/trial_balance.py

@ -3,7 +3,6 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from operator import itemgetter
from odoo import api, models
@ -203,10 +202,11 @@ class TrialBalanceReport(models.AbstractModel):
for initial_balance in initial_balances:
pl_initial_balance += initial_balance["balance"]
if foreign_currency:
pl_initial_currency_balance += initial_balance["amount_currency"]
pl_initial_currency_balance += round(
initial_balance["amount_currency"], 2
)
return pl_initial_balance, pl_initial_currency_balance
# flake8: noqa: C901
def _get_data(
self,
account_ids,
@ -222,6 +222,15 @@ class TrialBalanceReport(models.AbstractModel):
unaffected_earnings_account,
fy_start_date,
):
accounts_domain = [("company_id", "=", company_id)]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
accounts = self.env["account.account"].search(accounts_domain)
tb_initial_acc = []
for account in accounts:
tb_initial_acc.append(
{"account_id": account.id, "balance": 0.0, "amount_currency": 0.0}
)
initial_domain_bs = self._get_initial_balances_bs_ml_domain(
account_ids,
journal_ids,
@ -251,7 +260,18 @@ class TrialBalanceReport(models.AbstractModel):
fields=["account_id", "balance", "amount_currency"],
groupby=["account_id"],
)
tb_initial_acc = tb_initial_acc_bs + tb_initial_acc_pl
tb_initial_acc_rg = tb_initial_acc_bs + tb_initial_acc_pl
for account_rg in tb_initial_acc_rg:
element = list(
filter(
lambda acc_dict: acc_dict["account_id"]
== account_rg["account_id"][0],
tb_initial_acc,
)
)
if element:
element[0]["balance"] += account_rg["balance"]
element[0]["amount_currency"] += account_rg["amount_currency"]
if hide_account_at_0:
tb_initial_acc = [p for p in tb_initial_acc if p["balance"] != 0]
@ -311,9 +331,11 @@ class TrialBalanceReport(models.AbstractModel):
total_amount[acc_id]["ending_balance"] = tb["balance"]
if foreign_currency:
total_amount[acc_id]["initial_currency_balance"] = 0.0
total_amount[acc_id]["ending_currency_balance"] = tb["amount_currency"]
total_amount[acc_id]["ending_currency_balance"] = round(
tb["amount_currency"], 2
)
for tb in tb_initial_acc:
acc_id = tb["account_id"][0]
acc_id = tb["account_id"]
if acc_id not in total_amount.keys():
total_amount[acc_id] = {}
total_amount[acc_id]["credit"] = 0.0
@ -322,22 +344,22 @@ class TrialBalanceReport(models.AbstractModel):
total_amount[acc_id]["initial_balance"] = tb["balance"]
total_amount[acc_id]["ending_balance"] = tb["balance"]
if foreign_currency:
total_amount[acc_id]["initial_currency_balance"] = tb[
"amount_currency"
]
total_amount[acc_id]["ending_currency_balance"] = tb[
"amount_currency"
]
total_amount[acc_id]["initial_currency_balance"] = round(
tb["amount_currency"], 2
)
total_amount[acc_id]["ending_currency_balance"] = round(
tb["amount_currency"], 2
)
else:
total_amount[acc_id]["initial_balance"] = tb["balance"]
total_amount[acc_id]["ending_balance"] += tb["balance"]
if foreign_currency:
total_amount[acc_id]["initial_currency_balance"] = tb[
"amount_currency"
]
total_amount[acc_id]["ending_currency_balance"] += tb[
"amount_currency"
]
total_amount[acc_id]["initial_currency_balance"] = round(
tb["amount_currency"], 2
)
total_amount[acc_id]["ending_currency_balance"] += round(
tb["amount_currency"], 2
)
if show_partner_details:
partners_ids = set()
partners_data = {}
@ -357,9 +379,9 @@ class TrialBalanceReport(models.AbstractModel):
total_amount[acc_id][prt_id]["ending_balance"] = tb["balance"]
if foreign_currency:
total_amount[acc_id][prt_id]["initial_currency_balance"] = 0.0
total_amount[acc_id][prt_id]["ending_currency_balance"] = tb[
"amount_currency"
]
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
tb["amount_currency"], 2
)
partners_ids.add(tb["partner_id"])
for tb in tb_initial_prt:
acc_id = tb["account_id"][0]
@ -379,10 +401,10 @@ class TrialBalanceReport(models.AbstractModel):
if foreign_currency:
total_amount[acc_id][prt_id][
"initial_currency_balance"
] = tb["amount_currency"]
] = round(tb["amount_currency"], 2)
total_amount[acc_id][prt_id][
"ending_currency_balance"
] = tb["amount_currency"]
] = round(tb["amount_currency"], 2)
partners_ids.add(tb["partner_id"])
elif prt_id not in total_amount[acc_id].keys():
total_amount[acc_id][prt_id] = {}
@ -394,10 +416,10 @@ class TrialBalanceReport(models.AbstractModel):
if foreign_currency:
total_amount[acc_id][prt_id][
"initial_currency_balance"
] = tb["amount_currency"]
] = round(tb["amount_currency"], 2)
total_amount[acc_id][prt_id][
"ending_currency_balance"
] = tb["amount_currency"]
] = round(tb["amount_currency"], 2)
partners_ids.add(tb["partner_id"])
else:
total_amount[acc_id][prt_id]["initial_balance"] += tb["balance"]
@ -405,10 +427,10 @@ class TrialBalanceReport(models.AbstractModel):
if foreign_currency:
total_amount[acc_id][prt_id][
"initial_currency_balance"
] += tb["amount_currency"]
] += round(tb["amount_currency"], 2)
total_amount[acc_id][prt_id][
"ending_currency_balance"
] += tb["amount_currency"]
] += round(tb["amount_currency"], 2)
accounts_ids = list(total_amount.keys())
unaffected_id = unaffected_earnings_account
if unaffected_id not in accounts_ids:

16
account_financial_report/report/vat_report.py

@ -2,6 +2,8 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import operator
from odoo import api, models
@ -19,6 +21,7 @@ class VATReport(models.AbstractModel):
"id": tax.id,
"name": tax.name,
"tax_group_id": tax.tax_group_id.id,
"type_tax_use": tax.type_tax_use,
}
}
)
@ -49,26 +52,27 @@ class VATReport(models.AbstractModel):
domain=domain, fields=ml_fields
)
vat_data = {}
tax_ids = set()
tax_ids = list(map(operator.itemgetter("tax_line_id"), tax_move_lines))
tax_ids = [i[0] for i in tax_ids]
tax_data = self._get_tax_data(tax_ids)
for tax_move_line in tax_move_lines:
tax_ml_id = tax_move_line["id"]
repartition = self.env["account.tax.repartition.line"].browse(
tax_move_line["tax_repartition_line_id"][0]
)
tax_id = tax_move_line["tax_line_id"][0]
vat_data[tax_ml_id] = {}
vat_data[tax_ml_id].update(
{
"id": tax_ml_id,
"net": tax_move_line["tax_base_amount"],
"tax": tax_move_line["balance"]
if tax_move_line["balance"] > 0
else (-1) * tax_move_line["balance"],
"tax": (-1) * tax_move_line["balance"]
if tax_data[tax_id]["type_tax_use"] == "sale"
else tax_move_line["balance"],
"tax_line_id": tax_move_line["tax_line_id"],
"tags_ids": repartition.tag_ids.ids,
}
)
tax_ids.add(tax_move_line["tax_line_id"][0])
tax_data = self._get_tax_data(tax_ids)
return vat_data, tax_data
def _get_tax_group_data(self, tax_group_ids):

2
account_financial_report/wizard/aged_partner_balance_wizard.py

@ -20,6 +20,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
string="Company",
)
date_at = fields.Date(required=True, default=fields.Date.context_today)
date_from = fields.Date(string="Date From")
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
@ -152,6 +153,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
return {
"wizard_id": self.id,
"date_at": self.date_at,
"date_from": self.date_from or False,
"only_posted_moves": self.target_move == "posted",
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,

1
account_financial_report/wizard/aged_partner_balance_wizard_view.xml

@ -16,6 +16,7 @@
<group name="filters">
<group name="date_range">
<field name="date_at" />
<field name="date_from" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio" />

2
account_financial_report/wizard/general_ledger_wizard.py

@ -85,6 +85,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
string="Account Code To",
help="Ending account in a range",
)
show_partner_details = fields.Boolean(string="Show Partner Details", default=True,)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
@ -300,6 +301,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"show_partner_details": self.show_partner_details,
"cost_center_ids": self.cost_center_ids.ids,
"analytic_tag_ids": self.analytic_tag_ids.ids,
"journal_ids": self.account_journal_ids.ids,

1
account_financial_report/wizard/general_ledger_wizard_view.xml

@ -26,6 +26,7 @@
<group name="other_filters">
<field name="target_move" widget="radio" />
<field name="centralize" />
<field name="show_partner_details" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
<field name="show_analytic_tags" />

Loading…
Cancel
Save