[IMP] account_financial_report: abstract for avoiding duplicated code and increase readability
parent
cf83c6e839
commit
0345a5c176
|
@ -3,6 +3,7 @@
|
||||||
# © 2016 Julien Coux (Camptocamp)
|
# © 2016 Julien Coux (Camptocamp)
|
||||||
# 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).-
|
||||||
|
|
||||||
|
from . import abstract_report
|
||||||
from . import abstract_report_xlsx
|
from . import abstract_report_xlsx
|
||||||
from . import aged_partner_balance
|
from . import aged_partner_balance
|
||||||
from . import aged_partner_balance_xlsx
|
from . import aged_partner_balance_xlsx
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
|
class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
|
_name = "report.account_financial_report.abstract_report"
|
||||||
|
_description = "Abstract Report"
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_move_lines_domain_not_reconciled(
|
||||||
|
self, company_id, account_ids, partner_ids, only_posted_moves, date_from
|
||||||
|
):
|
||||||
|
domain = [
|
||||||
|
("account_id", "in", account_ids),
|
||||||
|
("company_id", "=", company_id),
|
||||||
|
("reconciled", "=", False),
|
||||||
|
]
|
||||||
|
if partner_ids:
|
||||||
|
domain += [("partner_id", "in", partner_ids)]
|
||||||
|
if only_posted_moves:
|
||||||
|
domain += [("move_id.state", "=", "posted")]
|
||||||
|
else:
|
||||||
|
domain += [("move_id.state", "in", ["posted", "draft"])]
|
||||||
|
if date_from:
|
||||||
|
domain += [("date", ">", date_from)]
|
||||||
|
return domain
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_new_move_lines_domain(
|
||||||
|
self, new_ml_ids, account_ids, company_id, partner_ids, only_posted_moves
|
||||||
|
):
|
||||||
|
domain = [
|
||||||
|
("account_id", "in", account_ids),
|
||||||
|
("company_id", "=", company_id),
|
||||||
|
("id", "in", new_ml_ids),
|
||||||
|
]
|
||||||
|
if partner_ids:
|
||||||
|
domain += [("partner_id", "in", partner_ids)]
|
||||||
|
if only_posted_moves:
|
||||||
|
domain += [("move_id.state", "=", "posted")]
|
||||||
|
else:
|
||||||
|
domain += [("move_id.state", "in", ["posted", "draft"])]
|
||||||
|
return domain
|
||||||
|
|
||||||
|
def _recalculate_move_lines(
|
||||||
|
self,
|
||||||
|
move_lines,
|
||||||
|
debit_ids,
|
||||||
|
credit_ids,
|
||||||
|
debit_amount,
|
||||||
|
credit_amount,
|
||||||
|
ml_ids,
|
||||||
|
account_ids,
|
||||||
|
company_id,
|
||||||
|
partner_ids,
|
||||||
|
only_posted_moves,
|
||||||
|
):
|
||||||
|
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
|
||||||
|
)
|
||||||
|
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",
|
||||||
|
]
|
||||||
|
new_move_lines = self.env["account.move.line"].search_read(
|
||||||
|
domain=new_domain, fields=ml_fields
|
||||||
|
)
|
||||||
|
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
|
||||||
|
|
||||||
|
def _get_accounts_data(self, accounts_ids):
|
||||||
|
accounts = self.env["account.account"].browse(accounts_ids)
|
||||||
|
accounts_data = {}
|
||||||
|
for account in accounts:
|
||||||
|
accounts_data.update(
|
||||||
|
{
|
||||||
|
account.id: {
|
||||||
|
"id": account.id,
|
||||||
|
"code": account.code,
|
||||||
|
"name": account.name,
|
||||||
|
"hide_account": False,
|
||||||
|
"group_id": account.group_id.id,
|
||||||
|
"currency_id": account.currency_id or False,
|
||||||
|
"currency_name": account.currency_id.name,
|
||||||
|
"centralized": account.centralized,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return accounts_data
|
||||||
|
|
||||||
|
def _get_journals_data(self, journals_ids):
|
||||||
|
journals = self.env["account.journal"].browse(journals_ids)
|
||||||
|
journals_data = {}
|
||||||
|
for journal in journals:
|
||||||
|
journals_data.update({journal.id: {"id": journal.id, "code": journal.code}})
|
||||||
|
return journals_data
|
|
@ -12,6 +12,7 @@ from odoo.tools import float_is_zero
|
||||||
class AgedPartnerBalanceReport(models.AbstractModel):
|
class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
_name = "report.account_financial_report.aged_partner_balance"
|
_name = "report.account_financial_report.aged_partner_balance"
|
||||||
_description = "Aged Partner Balance Report"
|
_description = "Aged Partner Balance Report"
|
||||||
|
_inherit = "report.account_financial_report.abstract_report"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _initialize_account(self, ag_pb_data, acc_id):
|
def _initialize_account(self, ag_pb_data, acc_id):
|
||||||
|
@ -40,47 +41,6 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
ag_pb_data[acc_id][prt_id]["move_lines"] = []
|
ag_pb_data[acc_id][prt_id]["move_lines"] = []
|
||||||
return ag_pb_data
|
return ag_pb_data
|
||||||
|
|
||||||
def _get_journals_data(self, journals_ids):
|
|
||||||
journals = self.env["account.journal"].browse(journals_ids)
|
|
||||||
journals_data = {}
|
|
||||||
for journal in journals:
|
|
||||||
journals_data.update({journal.id: {"id": journal.id, "code": journal.code}})
|
|
||||||
return journals_data
|
|
||||||
|
|
||||||
def _get_accounts_data(self, accounts_ids):
|
|
||||||
accounts = self.env["account.account"].browse(accounts_ids)
|
|
||||||
accounts_data = {}
|
|
||||||
for account in accounts:
|
|
||||||
accounts_data.update(
|
|
||||||
{
|
|
||||||
account.id: {
|
|
||||||
"id": account.id,
|
|
||||||
"code": account.code,
|
|
||||||
"name": account.name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return accounts_data
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_move_lines_domain(
|
|
||||||
self, company_id, account_ids, partner_ids, only_posted_moves, date_from
|
|
||||||
):
|
|
||||||
domain = [
|
|
||||||
("account_id", "in", account_ids),
|
|
||||||
("company_id", "=", company_id),
|
|
||||||
("reconciled", "=", False),
|
|
||||||
]
|
|
||||||
if partner_ids:
|
|
||||||
domain += [("partner_id", "in", partner_ids)]
|
|
||||||
if only_posted_moves:
|
|
||||||
domain += [("move_id.state", "=", "posted")]
|
|
||||||
else:
|
|
||||||
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
||||||
if date_from:
|
|
||||||
domain += [("date", ">", date_from)]
|
|
||||||
return domain
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _calculate_amounts(
|
def _calculate_amounts(
|
||||||
self, ag_pb_data, acc_id, prt_id, residual, due_date, date_at_object
|
self, ag_pb_data, acc_id, prt_id, residual, due_date, date_at_object
|
||||||
|
@ -130,72 +90,6 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
)
|
)
|
||||||
return accounts_partial_reconcile, debit_amount, credit_amount
|
return accounts_partial_reconcile, debit_amount, credit_amount
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_new_move_lines_domain(
|
|
||||||
self, new_ml_ids, account_ids, company_id, partner_ids, only_posted_moves
|
|
||||||
):
|
|
||||||
domain = [
|
|
||||||
("account_id", "in", account_ids),
|
|
||||||
("company_id", "=", company_id),
|
|
||||||
("id", "in", new_ml_ids),
|
|
||||||
]
|
|
||||||
if partner_ids:
|
|
||||||
domain += [("partner_id", "in", partner_ids)]
|
|
||||||
if only_posted_moves:
|
|
||||||
domain += [("move_id.state", "=", "posted")]
|
|
||||||
else:
|
|
||||||
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
||||||
return domain
|
|
||||||
|
|
||||||
def _recalculate_move_lines(
|
|
||||||
self,
|
|
||||||
move_lines,
|
|
||||||
debit_ids,
|
|
||||||
credit_ids,
|
|
||||||
debit_amount,
|
|
||||||
credit_amount,
|
|
||||||
ml_ids,
|
|
||||||
account_ids,
|
|
||||||
company_id,
|
|
||||||
partner_ids,
|
|
||||||
only_posted_moves,
|
|
||||||
):
|
|
||||||
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
|
|
||||||
)
|
|
||||||
ml_fields = [
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"date",
|
|
||||||
"move_id",
|
|
||||||
"journal_id",
|
|
||||||
"account_id",
|
|
||||||
"partner_id",
|
|
||||||
"amount_residual",
|
|
||||||
"date_maturity",
|
|
||||||
"ref",
|
|
||||||
"reconciled",
|
|
||||||
]
|
|
||||||
new_move_lines = self.env["account.move.line"].search_read(
|
|
||||||
domain=new_domain, fields=ml_fields
|
|
||||||
)
|
|
||||||
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
|
|
||||||
|
|
||||||
def _get_move_lines_data(
|
def _get_move_lines_data(
|
||||||
self,
|
self,
|
||||||
company_id,
|
company_id,
|
||||||
|
@ -206,7 +100,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||||
only_posted_moves,
|
only_posted_moves,
|
||||||
show_move_line_details,
|
show_move_line_details,
|
||||||
):
|
):
|
||||||
domain = self._get_move_lines_domain(
|
domain = self._get_move_lines_domain_not_reconciled(
|
||||||
company_id, account_ids, partner_ids, only_posted_moves, date_from
|
company_id, account_ids, partner_ids, only_posted_moves, date_from
|
||||||
)
|
)
|
||||||
ml_fields = [
|
ml_fields = [
|
||||||
|
|
|
@ -13,32 +13,7 @@ from odoo.tools import float_is_zero
|
||||||
class GeneralLedgerReport(models.AbstractModel):
|
class GeneralLedgerReport(models.AbstractModel):
|
||||||
_name = "report.account_financial_report.general_ledger"
|
_name = "report.account_financial_report.general_ledger"
|
||||||
_description = "General Ledger Report"
|
_description = "General Ledger Report"
|
||||||
|
_inherit = "report.account_financial_report.abstract_report"
|
||||||
def _get_accounts_data(self, account_ids):
|
|
||||||
accounts = self.env["account.account"].browse(account_ids)
|
|
||||||
accounts_data = {}
|
|
||||||
for account in accounts:
|
|
||||||
accounts_data.update(
|
|
||||||
{
|
|
||||||
account.id: {
|
|
||||||
"id": account.id,
|
|
||||||
"code": account.code,
|
|
||||||
"name": account.name,
|
|
||||||
"group_id": account.group_id.id,
|
|
||||||
"currency_id": account.currency_id or False,
|
|
||||||
"currency_name": account.currency_id.name,
|
|
||||||
"centralized": account.centralized,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return accounts_data
|
|
||||||
|
|
||||||
def _get_journals_data(self, journals_ids):
|
|
||||||
journals = self.env["account.journal"].browse(journals_ids)
|
|
||||||
journals_data = {}
|
|
||||||
for journal in journals:
|
|
||||||
journals_data.update({journal.id: {"id": journal.id, "code": journal.code}})
|
|
||||||
return journals_data
|
|
||||||
|
|
||||||
def _get_tags_data(self, tags_ids):
|
def _get_tags_data(self, tags_ids):
|
||||||
tags = self.env["account.analytic.tag"].browse(tags_ids)
|
tags = self.env["account.analytic.tag"].browse(tags_ids)
|
||||||
|
|
|
@ -12,23 +12,7 @@ from odoo.tools import float_is_zero
|
||||||
class OpenItemsReport(models.AbstractModel):
|
class OpenItemsReport(models.AbstractModel):
|
||||||
_name = "report.account_financial_report.open_items"
|
_name = "report.account_financial_report.open_items"
|
||||||
_description = "Open Items Report"
|
_description = "Open Items Report"
|
||||||
|
_inherit = "report.account_financial_report.abstract_report"
|
||||||
@api.model
|
|
||||||
def get_html(self, given_context=None):
|
|
||||||
return self._get_html()
|
|
||||||
|
|
||||||
def _get_html(self):
|
|
||||||
result = {}
|
|
||||||
rcontext = {}
|
|
||||||
context = dict(self.env.context)
|
|
||||||
rcontext.update(context.get("data"))
|
|
||||||
active_id = context.get("active_id")
|
|
||||||
wiz = self.env["open.items.report.wizard"].browse(active_id)
|
|
||||||
rcontext["o"] = wiz
|
|
||||||
result["html"] = self.env.ref(
|
|
||||||
"account_financial_report.report_open_items"
|
|
||||||
).render(rcontext)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _get_account_partial_reconciled(self, company_id, date_at_object):
|
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)]
|
||||||
|
@ -52,121 +36,6 @@ class OpenItemsReport(models.AbstractModel):
|
||||||
)
|
)
|
||||||
return accounts_partial_reconcile, debit_amount, credit_amount
|
return accounts_partial_reconcile, debit_amount, credit_amount
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_new_move_lines_domain(
|
|
||||||
self, new_ml_ids, account_ids, company_id, partner_ids, only_posted_moves
|
|
||||||
):
|
|
||||||
domain = [
|
|
||||||
("account_id", "in", account_ids),
|
|
||||||
("company_id", "=", company_id),
|
|
||||||
("id", "in", new_ml_ids),
|
|
||||||
]
|
|
||||||
if partner_ids:
|
|
||||||
domain += [("partner_id", "in", partner_ids)]
|
|
||||||
if only_posted_moves:
|
|
||||||
domain += [("move_id.state", "=", "posted")]
|
|
||||||
else:
|
|
||||||
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
||||||
return domain
|
|
||||||
|
|
||||||
def _recalculate_move_lines(
|
|
||||||
self,
|
|
||||||
move_lines,
|
|
||||||
debit_ids,
|
|
||||||
credit_ids,
|
|
||||||
debit_amount,
|
|
||||||
credit_amount,
|
|
||||||
ml_ids,
|
|
||||||
account_ids,
|
|
||||||
company_id,
|
|
||||||
partner_ids,
|
|
||||||
only_posted_moves,
|
|
||||||
):
|
|
||||||
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
|
|
||||||
)
|
|
||||||
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",
|
|
||||||
]
|
|
||||||
new_move_lines = self.env["account.move.line"].search_read(
|
|
||||||
domain=new_domain, fields=ml_fields
|
|
||||||
)
|
|
||||||
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, only_posted_moves, date_from
|
|
||||||
):
|
|
||||||
domain = [
|
|
||||||
("account_id", "in", account_ids),
|
|
||||||
("company_id", "=", company_id),
|
|
||||||
("reconciled", "=", False),
|
|
||||||
]
|
|
||||||
if partner_ids:
|
|
||||||
domain += [("partner_id", "in", partner_ids)]
|
|
||||||
if only_posted_moves:
|
|
||||||
domain += [("move_id.state", "=", "posted")]
|
|
||||||
else:
|
|
||||||
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
||||||
if date_from:
|
|
||||||
domain += [("date", ">", date_from)]
|
|
||||||
return domain
|
|
||||||
|
|
||||||
def _get_accounts_data(self, accounts_ids):
|
|
||||||
accounts = self.env["account.account"].browse(accounts_ids)
|
|
||||||
accounts_data = {}
|
|
||||||
for account in accounts:
|
|
||||||
accounts_data.update(
|
|
||||||
{
|
|
||||||
account.id: {
|
|
||||||
"id": account.id,
|
|
||||||
"code": account.code,
|
|
||||||
"name": account.name,
|
|
||||||
"hide_account": False,
|
|
||||||
"currency_id": account.currency_id or False,
|
|
||||||
"currency_name": account.currency_id.name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return accounts_data
|
|
||||||
|
|
||||||
def _get_journals_data(self, journals_ids):
|
|
||||||
journals = self.env["account.journal"].browse(journals_ids)
|
|
||||||
journals_data = {}
|
|
||||||
for journal in journals:
|
|
||||||
journals_data.update({journal.id: {"id": journal.id, "code": journal.code}})
|
|
||||||
return journals_data
|
|
||||||
|
|
||||||
def _get_data(
|
def _get_data(
|
||||||
self,
|
self,
|
||||||
account_ids,
|
account_ids,
|
||||||
|
@ -176,7 +45,7 @@ class OpenItemsReport(models.AbstractModel):
|
||||||
company_id,
|
company_id,
|
||||||
date_from,
|
date_from,
|
||||||
):
|
):
|
||||||
domain = self._get_move_lines_domain(
|
domain = self._get_move_lines_domain_not_reconciled(
|
||||||
company_id, account_ids, partner_ids, only_posted_moves, date_from
|
company_id, account_ids, partner_ids, only_posted_moves, date_from
|
||||||
)
|
)
|
||||||
ml_fields = [
|
ml_fields = [
|
||||||
|
|
|
@ -10,42 +10,7 @@ from odoo import api, models
|
||||||
class TrialBalanceReport(models.AbstractModel):
|
class TrialBalanceReport(models.AbstractModel):
|
||||||
_name = "report.account_financial_report.trial_balance"
|
_name = "report.account_financial_report.trial_balance"
|
||||||
_description = "Trial Balance Report"
|
_description = "Trial Balance Report"
|
||||||
|
_inherit = "report.account_financial_report.abstract_report"
|
||||||
@api.model
|
|
||||||
def get_html(self, given_context=None):
|
|
||||||
return self._get_html()
|
|
||||||
|
|
||||||
def _get_html(self):
|
|
||||||
result = {}
|
|
||||||
rcontext = {}
|
|
||||||
context = dict(self.env.context)
|
|
||||||
rcontext.update(context.get("data"))
|
|
||||||
active_id = context.get("active_id")
|
|
||||||
wiz = self.env["open.items.report.wizard"].browse(active_id)
|
|
||||||
rcontext["o"] = wiz
|
|
||||||
result["html"] = self.env.ref(
|
|
||||||
"account_financial_report.report_trial_balance"
|
|
||||||
).render(rcontext)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _get_accounts_data(self, account_ids):
|
|
||||||
accounts = self.env["account.account"].browse(account_ids)
|
|
||||||
accounts_data = {}
|
|
||||||
for account in accounts:
|
|
||||||
accounts_data.update(
|
|
||||||
{
|
|
||||||
account.id: {
|
|
||||||
"id": account.id,
|
|
||||||
"code": account.code,
|
|
||||||
"name": account.name,
|
|
||||||
"group_id": account.group_id.id,
|
|
||||||
"hide_account": False,
|
|
||||||
"currency_id": account.currency_id or False,
|
|
||||||
"currency_name": account.currency_id.name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return accounts_data
|
|
||||||
|
|
||||||
def _get_initial_balances_bs_ml_domain(
|
def _get_initial_balances_bs_ml_domain(
|
||||||
self,
|
self,
|
||||||
|
@ -260,6 +225,25 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
)
|
)
|
||||||
return total_amount
|
return total_amount
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _compute_acc_prt_amount(
|
||||||
|
self, total_amount, tb, acc_id, prt_id, foreign_currency
|
||||||
|
):
|
||||||
|
total_amount[acc_id][prt_id] = {}
|
||||||
|
total_amount[acc_id][prt_id]["credit"] = 0.0
|
||||||
|
total_amount[acc_id][prt_id]["debit"] = 0.0
|
||||||
|
total_amount[acc_id][prt_id]["balance"] = 0.0
|
||||||
|
total_amount[acc_id][prt_id]["initial_balance"] = tb["balance"]
|
||||||
|
total_amount[acc_id][prt_id]["ending_balance"] = tb["balance"]
|
||||||
|
if foreign_currency:
|
||||||
|
total_amount[acc_id][prt_id]["initial_currency_balance"] = round(
|
||||||
|
tb["amount_currency"], 2
|
||||||
|
)
|
||||||
|
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
|
||||||
|
tb["amount_currency"], 2
|
||||||
|
)
|
||||||
|
return total_amount
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _compute_partner_amount(
|
def _compute_partner_amount(
|
||||||
self, total_amount, tb_initial_prt, tb_period_prt, foreign_currency
|
self, total_amount, tb_initial_prt, tb_period_prt, foreign_currency
|
||||||
|
@ -295,33 +279,13 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
||||||
)
|
)
|
||||||
if acc_id not in total_amount.keys():
|
if acc_id not in total_amount.keys():
|
||||||
total_amount[acc_id][prt_id] = {}
|
total_amount = self._compute_acc_prt_amount(
|
||||||
total_amount[acc_id][prt_id]["credit"] = 0.0
|
total_amount, tb, acc_id, prt_id, foreign_currency
|
||||||
total_amount[acc_id][prt_id]["debit"] = 0.0
|
|
||||||
total_amount[acc_id][prt_id]["balance"] = 0.0
|
|
||||||
total_amount[acc_id][prt_id]["initial_balance"] = tb["balance"]
|
|
||||||
total_amount[acc_id][prt_id]["ending_balance"] = tb["balance"]
|
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id][prt_id][
|
|
||||||
"initial_currency_balance"
|
|
||||||
] = round(tb["amount_currency"], 2)
|
|
||||||
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
)
|
||||||
partners_ids.add(tb["partner_id"])
|
partners_ids.add(tb["partner_id"])
|
||||||
elif prt_id not in total_amount[acc_id].keys():
|
elif prt_id not in total_amount[acc_id].keys():
|
||||||
total_amount[acc_id][prt_id] = {}
|
total_amount = self._compute_acc_prt_amount(
|
||||||
total_amount[acc_id][prt_id]["credit"] = 0.0
|
total_amount, tb, acc_id, prt_id, foreign_currency
|
||||||
total_amount[acc_id][prt_id]["debit"] = 0.0
|
|
||||||
total_amount[acc_id][prt_id]["balance"] = 0.0
|
|
||||||
total_amount[acc_id][prt_id]["initial_balance"] = tb["balance"]
|
|
||||||
total_amount[acc_id][prt_id]["ending_balance"] = tb["balance"]
|
|
||||||
if foreign_currency:
|
|
||||||
total_amount[acc_id][prt_id][
|
|
||||||
"initial_currency_balance"
|
|
||||||
] = round(tb["amount_currency"], 2)
|
|
||||||
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
|
|
||||||
tb["amount_currency"], 2
|
|
||||||
)
|
)
|
||||||
partners_ids.add(tb["partner_id"])
|
partners_ids.add(tb["partner_id"])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -34,3 +34,18 @@ class AbstractWizard(models.AbstractModel):
|
||||||
required=False,
|
required=False,
|
||||||
string="Company",
|
string="Company",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def button_export_html(self):
|
||||||
|
self.ensure_one()
|
||||||
|
report_type = "qweb-html"
|
||||||
|
return self._export(report_type)
|
||||||
|
|
||||||
|
def button_export_pdf(self):
|
||||||
|
self.ensure_one()
|
||||||
|
report_type = "qweb-pdf"
|
||||||
|
return self._export(report_type)
|
||||||
|
|
||||||
|
def button_export_xlsx(self):
|
||||||
|
self.ensure_one()
|
||||||
|
report_type = "xlsx"
|
||||||
|
return self._export(report_type)
|
||||||
|
|
|
@ -127,21 +127,6 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
.report_action(self, data=data)
|
.report_action(self, data=data)
|
||||||
)
|
)
|
||||||
|
|
||||||
def button_export_html(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-html"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_pdf(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-pdf"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "xlsx"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def _prepare_report_aged_partner_balance(self):
|
def _prepare_report_aged_partner_balance(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -292,21 +292,6 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
.report_action(self, data=data)
|
.report_action(self, data=data)
|
||||||
)
|
)
|
||||||
|
|
||||||
def button_export_html(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-html"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_pdf(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-pdf"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "xlsx"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def _prepare_report_general_ledger(self):
|
def _prepare_report_general_ledger(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -95,20 +95,6 @@ class JournalLedgerReportWizard(models.TransientModel):
|
||||||
.report_action(self, data=data)
|
.report_action(self, data=data)
|
||||||
)
|
)
|
||||||
|
|
||||||
def button_export_html(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-html"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_pdf(self):
|
|
||||||
report_type = "qweb-pdf"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "xlsx"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def _prepare_report_journal_ledger(self):
|
def _prepare_report_journal_ledger(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
journals = self.journal_ids
|
journals = self.journal_ids
|
||||||
|
|
|
@ -151,21 +151,6 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||||
.report_action(self, data=data)
|
.report_action(self, data=data)
|
||||||
)
|
)
|
||||||
|
|
||||||
def button_export_html(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-html"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_pdf(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-pdf"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "xlsx"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def _prepare_report_open_items(self):
|
def _prepare_report_open_items(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -252,21 +252,6 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||||
.report_action(self, data=data)
|
.report_action(self, data=data)
|
||||||
)
|
)
|
||||||
|
|
||||||
def button_export_html(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-html"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_pdf(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-pdf"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "xlsx"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def _prepare_report_trial_balance(self):
|
def _prepare_report_trial_balance(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -8,13 +8,8 @@ from odoo.exceptions import ValidationError
|
||||||
class VATReportWizard(models.TransientModel):
|
class VATReportWizard(models.TransientModel):
|
||||||
_name = "vat.report.wizard"
|
_name = "vat.report.wizard"
|
||||||
_description = "VAT Report Wizard"
|
_description = "VAT Report Wizard"
|
||||||
|
_inherit = "account_financial_report_abstract_wizard"
|
||||||
|
|
||||||
company_id = fields.Many2one(
|
|
||||||
comodel_name="res.company",
|
|
||||||
default=lambda self: self.env.company.id,
|
|
||||||
required=False,
|
|
||||||
string="Company",
|
|
||||||
)
|
|
||||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
||||||
date_from = fields.Date("Start Date", required=True)
|
date_from = fields.Date("Start Date", required=True)
|
||||||
date_to = fields.Date("End Date", required=True)
|
date_to = fields.Date("End Date", required=True)
|
||||||
|
@ -88,21 +83,6 @@ class VATReportWizard(models.TransientModel):
|
||||||
.report_action(self, data=data)
|
.report_action(self, data=data)
|
||||||
)
|
)
|
||||||
|
|
||||||
def button_export_html(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-html"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_pdf(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "qweb-pdf"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def button_export_xlsx(self):
|
|
||||||
self.ensure_one()
|
|
||||||
report_type = "xlsx"
|
|
||||||
return self._export(report_type)
|
|
||||||
|
|
||||||
def _prepare_vat_report(self):
|
def _prepare_vat_report(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue