[MIG] account_financial_report: Migration to 13.0
This commit is contained in:
@@ -6,6 +6,7 @@ from odoo import models
|
||||
|
||||
class AbstractReportXslx(models.AbstractModel):
|
||||
_name = "report.account_financial_report.abstract_report_xlsx"
|
||||
_description = "Abstract XLSX Account Financial Report"
|
||||
_inherit = "report.report_xlsx.abstract"
|
||||
|
||||
def __init__(self, pool, cr):
|
||||
@@ -255,7 +256,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
and not isinstance(value, bool)
|
||||
and not isinstance(value, int)
|
||||
):
|
||||
value = value.strftime("%d/%m/%Y")
|
||||
value = value and value.strftime("%d/%m/%Y")
|
||||
self.sheet.write_string(self.row_pos, col_pos, value or "")
|
||||
elif cell_type == "amount":
|
||||
if (
|
||||
@@ -444,10 +445,10 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
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 = getattr(self, "format_amount_bold")
|
||||
format_amt = self.format_amount_bold
|
||||
field_prefix = "format_amount_bold"
|
||||
else:
|
||||
format_amt = getattr(self, "format_amount")
|
||||
format_amt = self.format_amount
|
||||
field_prefix = "format_amount"
|
||||
if line_object.currency_id:
|
||||
field_name = "{}_{}".format(field_prefix, line_object.currency_id.name)
|
||||
@@ -455,7 +456,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
format_amt = getattr(self, field_name)
|
||||
else:
|
||||
format_amt = self.workbook.add_format()
|
||||
setattr(self, "field_name", format_amt)
|
||||
self.field_name = format_amt
|
||||
format_amount = "#,##0." + (
|
||||
"0" * line_object.currency_id.decimal_places
|
||||
)
|
||||
@@ -465,10 +466,10 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
def _get_currency_amt_format_dict(self, line_dict):
|
||||
""" Return amount format specific for each currency. """
|
||||
if line_dict.get("account_group_id", False) and line_dict["account_group_id"]:
|
||||
format_amt = getattr(self, "format_amount_bold")
|
||||
format_amt = self.format_amount_bold
|
||||
field_prefix = "format_amount_bold"
|
||||
else:
|
||||
format_amt = getattr(self, "format_amount")
|
||||
format_amt = 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"]])
|
||||
@@ -477,14 +478,14 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
format_amt = getattr(self, field_name)
|
||||
else:
|
||||
format_amt = self.workbook.add_format()
|
||||
setattr(self, "field_name", format_amt)
|
||||
self.field_name = format_amt
|
||||
format_amount = "#,##0." + ("0" * currency.decimal_places)
|
||||
format_amt.set_num_format(format_amount)
|
||||
return format_amt
|
||||
|
||||
def _get_currency_amt_header_format(self, line_object):
|
||||
""" Return amount header format for each currency. """
|
||||
format_amt = getattr(self, "format_header_amount")
|
||||
format_amt = self.format_header_amount
|
||||
if line_object.currency_id:
|
||||
field_name = "format_header_amount_%s" % line_object.currency_id.name
|
||||
if hasattr(self, field_name):
|
||||
@@ -493,7 +494,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
format_amt = self.workbook.add_format(
|
||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||
)
|
||||
setattr(self, "field_name", format_amt)
|
||||
self.field_name = format_amt
|
||||
format_amount = "#,##0." + (
|
||||
"0" * line_object.currency_id.decimal_places
|
||||
)
|
||||
@@ -502,7 +503,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
|
||||
def _get_currency_amt_header_format_dict(self, line_object):
|
||||
""" Return amount header format for each currency. """
|
||||
format_amt = getattr(self, "format_header_amount")
|
||||
format_amt = self.format_header_amount
|
||||
if line_object["currency_id"]:
|
||||
field_name = "format_header_amount_%s" % line_object["currency_name"]
|
||||
if hasattr(self, field_name):
|
||||
@@ -511,7 +512,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
format_amt = self.workbook.add_format(
|
||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||
)
|
||||
setattr(self, "field_name", format_amt)
|
||||
self.field_name = format_amt
|
||||
format_amount = "#,##0." + (
|
||||
"0" * line_object["currency_id"].decimal_places
|
||||
)
|
||||
@@ -527,8 +528,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
def _get_report_complete_name(self, report, prefix, data=None):
|
||||
if report.company_id:
|
||||
suffix = " - {} - {}".format(
|
||||
report.company_id.name,
|
||||
report.company_id.currency_id.name,
|
||||
report.company_id.name, report.company_id.currency_id.name
|
||||
)
|
||||
return prefix + suffix
|
||||
return prefix
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.tools import float_is_zero
|
||||
|
||||
|
||||
class AgedPartnerBalanceReport(models.AbstractModel):
|
||||
_name = "report.account_financial_report.aged_partner_balance"
|
||||
_description = "Aged Partner Balance Report"
|
||||
|
||||
@api.model
|
||||
def _initialize_account(self, ag_pb_data, acc_id):
|
||||
@@ -122,7 +121,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||
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,}
|
||||
{"debit_move_id": debit_move_id, "credit_move_id": credit_move_id}
|
||||
)
|
||||
return accounts_partial_reconcile, debit_amount, credit_amount
|
||||
|
||||
@@ -215,7 +214,6 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||
move_lines = self.env["account.move.line"].search_read(
|
||||
domain=domain, fields=ml_fields
|
||||
)
|
||||
ml_ids = set(pd.DataFrame(move_lines).id.to_list())
|
||||
journals_ids = set()
|
||||
partners_ids = set()
|
||||
partners_data = {}
|
||||
@@ -227,9 +225,9 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||
credit_amount,
|
||||
) = self._get_account_partial_reconciled(company_id, date_at_object)
|
||||
if acc_partial_rec:
|
||||
acc_partial_rec_data = pd.DataFrame(acc_partial_rec)
|
||||
debit_ids = set(acc_partial_rec_data.debit_move_id.to_list())
|
||||
credit_ids = set(acc_partial_rec_data.credit_move_id.to_list())
|
||||
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)
|
||||
move_lines = self._recalculate_move_lines(
|
||||
move_lines,
|
||||
debit_ids,
|
||||
@@ -414,7 +412,6 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
||||
)
|
||||
return aged_partner_data
|
||||
|
||||
@api.multi
|
||||
def _get_report_values(self, docids, data):
|
||||
wizard_id = data["wizard_id"]
|
||||
company = self.env["res.company"].browse(data["company_id"])
|
||||
@@ -423,6 +420,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()
|
||||
|
||||
only_posted_moves = data["only_posted_moves"]
|
||||
show_move_line_details = data["show_move_line_details"]
|
||||
(
|
||||
|
||||
@@ -7,6 +7,7 @@ from odoo import _, models
|
||||
|
||||
class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||
_name = "report.a_f_r.report_aged_partner_balance_xlsx"
|
||||
_description = "Aged Partner Balance XLSL Report"
|
||||
_inherit = "report.account_financial_report.abstract_report_xlsx"
|
||||
|
||||
def _get_report_name(self, report, data=False):
|
||||
|
||||
@@ -4,15 +4,13 @@
|
||||
|
||||
import calendar
|
||||
import datetime
|
||||
from operator import itemgetter
|
||||
|
||||
from natsort import natsorted
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class GeneralLedgerReport(models.AbstractModel):
|
||||
_name = "report.account_financial_report.general_ledger"
|
||||
_description = "General Ledger Report"
|
||||
|
||||
def _get_accounts_data(self, account_ids):
|
||||
accounts = self.env["account.account"].browse(account_ids)
|
||||
@@ -601,7 +599,6 @@ class GeneralLedgerReport(models.AbstractModel):
|
||||
list_centralized_ml += list(centralized_ml[jnl_id].values())
|
||||
return list_centralized_ml
|
||||
|
||||
@api.multi
|
||||
def _get_report_values(self, docids, data):
|
||||
wizard_id = data["wizard_id"]
|
||||
company = self.env["res.company"].browse(data["company_id"])
|
||||
@@ -669,7 +666,7 @@ class GeneralLedgerReport(models.AbstractModel):
|
||||
account["move_lines"] = centralized_ml
|
||||
account["partners"] = False
|
||||
del account["list_partner"]
|
||||
general_ledger = natsorted(general_ledger, key=itemgetter("code"))
|
||||
general_ledger = sorted(general_ledger, key=lambda k: k["code"])
|
||||
return {
|
||||
"doc_ids": [wizard_id],
|
||||
"doc_model": "general.ledger.report.wizard",
|
||||
|
||||
@@ -8,6 +8,7 @@ from odoo import _, models
|
||||
|
||||
class GeneralLedgerXslx(models.AbstractModel):
|
||||
_name = "report.a_f_r.report_general_ledger_xlsx"
|
||||
_description = "General Ledger XLSL Report"
|
||||
_inherit = "report.account_financial_report.abstract_report_xlsx"
|
||||
|
||||
def _get_report_name(self, report, data=False):
|
||||
@@ -93,7 +94,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
_("Account balance at 0 filter"),
|
||||
_("Hide") if report.hide_account_at_0 else _("Show"),
|
||||
],
|
||||
[_("Centralize filter"), _("Yes") if report.centralize else _("No"),],
|
||||
[_("Centralize filter"), _("Yes") if report.centralize else _("No")],
|
||||
[
|
||||
_("Show analytic tags"),
|
||||
_("Yes") if report.show_analytic_tags else _("No"),
|
||||
@@ -119,6 +120,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
def _get_col_pos_final_balance_label(self):
|
||||
return 5
|
||||
|
||||
# flake8: noqa: C901
|
||||
def _generate_report_content(self, workbook, report, data):
|
||||
res_data = self.env[
|
||||
"report.account_financial_report.general_ledger"
|
||||
@@ -152,7 +154,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
)
|
||||
if foreign_currency:
|
||||
account.update(
|
||||
{"initial_bal_curr": account["init_bal"]["bal_curr"],}
|
||||
{"initial_bal_curr": account["init_bal"]["bal_curr"]}
|
||||
)
|
||||
self.write_initial_balance_from_dict(account)
|
||||
|
||||
@@ -184,7 +186,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
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)
|
||||
|
||||
@@ -210,7 +212,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
)
|
||||
if foreign_currency:
|
||||
partner.update(
|
||||
{"initial_bal_culrr": partner["init_bal"]["bal_curr"],}
|
||||
{"initial_bal_culrr": partner["init_bal"]["bal_curr"]}
|
||||
)
|
||||
self.write_initial_balance_from_dict(partner)
|
||||
|
||||
@@ -235,7 +237,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
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)
|
||||
|
||||
@@ -249,7 +251,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
)
|
||||
if foreign_currency:
|
||||
partner.update(
|
||||
{"final_bal_curr": partner["fin_bal"]["bal_curr"],}
|
||||
{"final_bal_curr": partner["fin_bal"]["bal_curr"]}
|
||||
)
|
||||
self.write_ending_balance_from_dict(partner)
|
||||
|
||||
@@ -266,9 +268,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
}
|
||||
)
|
||||
if foreign_currency:
|
||||
account.update(
|
||||
{"final_bal_curr": account["fin_bal"]["bal_curr"],}
|
||||
)
|
||||
account.update({"final_bal_curr": account["fin_bal"]["bal_curr"]})
|
||||
self.write_ending_balance_from_dict(account)
|
||||
|
||||
# 2 lines break
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
import itertools
|
||||
import operator
|
||||
|
||||
from odoo import api, models
|
||||
from odoo import models
|
||||
|
||||
|
||||
class JournalLedgerReport(models.AbstractModel):
|
||||
_name = "report.account_financial_report.journal_ledger"
|
||||
_description = "Journal Ledger Report"
|
||||
|
||||
def _get_journal_ledger_data(self, journal):
|
||||
return {
|
||||
@@ -79,9 +80,7 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
|
||||
def _get_move_lines_domain(self, move_ids, wizard, journal_ids):
|
||||
|
||||
return [
|
||||
("move_id", "in", move_ids),
|
||||
]
|
||||
return [("move_id", "in", move_ids)]
|
||||
|
||||
def _get_move_lines_order(self, move_ids, wizard, journal_ids):
|
||||
return ""
|
||||
@@ -140,9 +139,7 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
return data
|
||||
|
||||
def _get_partner_id_data(self, partner):
|
||||
return {
|
||||
"name": partner.name,
|
||||
}
|
||||
return {"name": partner.name}
|
||||
|
||||
def _get_currency_data(self, currencies):
|
||||
data = {}
|
||||
@@ -151,9 +148,7 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
return data
|
||||
|
||||
def _get_currency_id_data(self, currency):
|
||||
return {
|
||||
"name": currency.name,
|
||||
}
|
||||
return {"name": currency.name}
|
||||
|
||||
def _get_tax_line_data(self, taxes):
|
||||
data = {}
|
||||
@@ -162,10 +157,7 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
return data
|
||||
|
||||
def _get_tax_line_id_data(self, tax):
|
||||
return {
|
||||
"name": tax.name,
|
||||
"description": tax.description,
|
||||
}
|
||||
return {"name": tax.name, "description": tax.description}
|
||||
|
||||
def _get_query_taxes(self):
|
||||
return """
|
||||
@@ -178,33 +170,32 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
"""
|
||||
|
||||
def _get_query_taxes_params(self, move_lines):
|
||||
return {
|
||||
"move_line_ids": tuple(move_lines.ids),
|
||||
}
|
||||
return {"move_line_ids": tuple(move_lines.ids)}
|
||||
|
||||
def _get_move_lines(self, move_ids, wizard, journal_ids):
|
||||
move_lines = self.env["account.move.line"].search(
|
||||
self._get_move_lines_domain(move_ids, wizard, journal_ids),
|
||||
order=self._get_move_lines_order(move_ids, wizard, journal_ids),
|
||||
)
|
||||
# Get the taxes ids for the move lines
|
||||
query_taxes_params = self._get_query_taxes_params(move_lines)
|
||||
query_taxes = self._get_query_taxes()
|
||||
move_line_ids_taxes_data = {}
|
||||
self.env.cr.execute(query_taxes, query_taxes_params)
|
||||
# Fetch the taxes associated to the move line
|
||||
for (
|
||||
move_line_id,
|
||||
account_tax_id,
|
||||
tax_description,
|
||||
tax_name,
|
||||
) in self.env.cr.fetchall():
|
||||
if move_line_id not in move_line_ids_taxes_data.keys():
|
||||
move_line_ids_taxes_data[move_line_id] = {}
|
||||
move_line_ids_taxes_data[move_line_id][account_tax_id] = {
|
||||
"name": tax_name,
|
||||
"description": tax_description,
|
||||
}
|
||||
if move_lines:
|
||||
# Get the taxes ids for the move lines
|
||||
query_taxes_params = self._get_query_taxes_params(move_lines)
|
||||
query_taxes = self._get_query_taxes()
|
||||
self.env.cr.execute(query_taxes, query_taxes_params)
|
||||
# Fetch the taxes associated to the move line
|
||||
for (
|
||||
move_line_id,
|
||||
account_tax_id,
|
||||
tax_description,
|
||||
tax_name,
|
||||
) in self.env.cr.fetchall():
|
||||
if move_line_id not in move_line_ids_taxes_data.keys():
|
||||
move_line_ids_taxes_data[move_line_id] = {}
|
||||
move_line_ids_taxes_data[move_line_id][account_tax_id] = {
|
||||
"name": tax_name,
|
||||
"description": tax_description,
|
||||
}
|
||||
Move_Lines = {}
|
||||
accounts = self.env["account.account"]
|
||||
partners = self.env["res.partner"]
|
||||
@@ -292,7 +283,6 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
]
|
||||
return journals_taxes_data_2
|
||||
|
||||
@api.multi
|
||||
def _get_report_values(self, docids, data):
|
||||
wizard_id = data["wizard_id"]
|
||||
wizard = self.env["journal.ledger.report.wizard"].browse(wizard_id)
|
||||
@@ -313,15 +303,12 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
partner_ids_data
|
||||
) = currency_ids_data = tax_line_ids_data = move_line_ids_taxes_data = {}
|
||||
if move_ids:
|
||||
(
|
||||
move_line_ids,
|
||||
move_lines_data,
|
||||
account_ids_data,
|
||||
partner_ids_data,
|
||||
currency_ids_data,
|
||||
tax_line_ids_data,
|
||||
move_line_ids_taxes_data,
|
||||
) = self._get_move_lines(move_ids, wizard, journal_ids)
|
||||
move_lines = self._get_move_lines(move_ids, wizard, journal_ids)
|
||||
move_lines_data = move_lines[1]
|
||||
account_ids_data = move_lines[2]
|
||||
partner_ids_data = move_lines[3]
|
||||
currency_ids_data = move_lines[4]
|
||||
tax_line_ids_data = move_lines[5]
|
||||
for move_data in moves_data:
|
||||
move_id = move_data["move_id"]
|
||||
move_data["report_move_lines"] = []
|
||||
@@ -338,10 +325,7 @@ class JournalLedgerReport(models.AbstractModel):
|
||||
for move_line_data in move_lines_data[move_id]:
|
||||
journal_id = move_line_data["journal_id"]
|
||||
if journal_id not in journal_totals.keys():
|
||||
journal_totals[journal_id] = {
|
||||
"debit": 0.0,
|
||||
"credit": 0.0,
|
||||
}
|
||||
journal_totals[journal_id] = {"debit": 0.0, "credit": 0.0}
|
||||
for item in ["debit", "credit"]:
|
||||
journal_totals[journal_id][item] += move_line_data[item]
|
||||
for journal_ledger_data in journal_ledgers_data:
|
||||
|
||||
@@ -8,6 +8,7 @@ from odoo import _, models
|
||||
|
||||
class JournalLedgerXslx(models.AbstractModel):
|
||||
_name = "report.a_f_r.report_journal_ledger_xlsx"
|
||||
_description = "Journal Ledger XLSX Report"
|
||||
_inherit = "report.account_financial_report.abstract_report_xlsx"
|
||||
|
||||
def _get_report_name(self, report, data=False):
|
||||
@@ -35,7 +36,7 @@ class JournalLedgerXslx(models.AbstractModel):
|
||||
{"header": _("Partner"), "field": "partner", "width": 25},
|
||||
{"header": _("Ref - Label"), "field": "label", "width": 40},
|
||||
{"header": _("Taxes"), "field": "taxes_description", "width": 11},
|
||||
{"header": _("Debit"), "field": "debit", "type": "amount", "width": 14,},
|
||||
{"header": _("Debit"), "field": "debit", "type": "amount", "width": 14},
|
||||
{"header": _("Credit"), "field": "credit", "type": "amount", "width": 14},
|
||||
]
|
||||
|
||||
@@ -188,7 +189,9 @@ class JournalLedgerXslx(models.AbstractModel):
|
||||
and journal.currency_id.name
|
||||
or journal.company_id.currency_id.name
|
||||
)
|
||||
sheet_name = "Tax - {} ({}) - {}".format(journal.code, currency_name, journal.name)
|
||||
sheet_name = "Tax - {} ({}) - {}".format(
|
||||
journal.code, currency_name, journal.name
|
||||
)
|
||||
self._generate_taxes_summary(workbook, sheet_name, ledger["tax_lines"])
|
||||
|
||||
def _generate_moves_content(self, workbook, sheet_name, report, res_data, moves):
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
from datetime import date, datetime
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import float_is_zero
|
||||
@@ -13,6 +11,7 @@ from odoo.tools import float_is_zero
|
||||
|
||||
class OpenItemsReport(models.AbstractModel):
|
||||
_name = "report.account_financial_report.open_items"
|
||||
_description = "Open Items Report"
|
||||
|
||||
@api.model
|
||||
def get_html(self, given_context=None):
|
||||
@@ -63,7 +62,7 @@ class OpenItemsReport(models.AbstractModel):
|
||||
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,}
|
||||
{"debit_move_id": debit_move_id, "credit_move_id": credit_move_id}
|
||||
)
|
||||
return (
|
||||
accounts_partial_reconcile,
|
||||
@@ -188,6 +187,7 @@ 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,
|
||||
@@ -201,12 +201,11 @@ class OpenItemsReport(models.AbstractModel):
|
||||
account_ids, partner_ids, date_at_object, target_move, company_id, date_from
|
||||
)
|
||||
self._cr.execute(query)
|
||||
move_lines_data = pd.DataFrame(self._cr.dictfetchall())
|
||||
account_ids = set(move_lines_data.account_id.to_list())
|
||||
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 = set(move_lines_data.journal_id.to_list())
|
||||
journal_ids = map(lambda r: r["journal_id"], move_lines_data)
|
||||
journals_data = self._get_journals_data(list(journal_ids))
|
||||
move_lines_data = move_lines_data.fillna(0).to_dict(orient="records")
|
||||
|
||||
if date_at_object < date.today():
|
||||
(
|
||||
@@ -215,12 +214,11 @@ class OpenItemsReport(models.AbstractModel):
|
||||
credit_accounts_partial_amount,
|
||||
) = self._get_account_partial_reconciled(move_lines_data, date_at_object)
|
||||
if accounts_partial_reconcile:
|
||||
accounts_partial_reconcile_data = pd.DataFrame(
|
||||
accounts_partial_reconcile
|
||||
debit_ids = map(
|
||||
operator.itemgetter("debit_move_id"), accounts_partial_reconcile
|
||||
)
|
||||
debit_ids = set(accounts_partial_reconcile_data.debit_move_id.to_list())
|
||||
credit_ids = set(
|
||||
accounts_partial_reconcile_data.credit_move_id.to_list()
|
||||
credit_ids = map(
|
||||
operator.itemgetter("credit_move_id"), accounts_partial_reconcile
|
||||
)
|
||||
for move_line in move_lines_data:
|
||||
if move_line["id"] in debit_ids:
|
||||
@@ -245,7 +243,7 @@ class OpenItemsReport(models.AbstractModel):
|
||||
for move_line in move_lines_data:
|
||||
no_partner = True
|
||||
# Partners data
|
||||
if move_line["partner_id"] and not pd.isna(move_line["partner_id"]):
|
||||
if move_line["partner_id"]:
|
||||
no_partner = False
|
||||
partners_data.update(
|
||||
{
|
||||
@@ -270,11 +268,11 @@ class OpenItemsReport(models.AbstractModel):
|
||||
original = move_line["credit"] * (-1)
|
||||
if not float_is_zero(move_line["debit"], precision_digits=2):
|
||||
original = move_line["debit"]
|
||||
|
||||
move_line.update(
|
||||
{
|
||||
"date": move_line["date"].strftime("%d/%m/%Y"),
|
||||
"date_maturity": move_line["date_maturity"].strftime("%d/%m/%Y"),
|
||||
"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"],
|
||||
@@ -325,7 +323,6 @@ class OpenItemsReport(models.AbstractModel):
|
||||
total_amount[account_id]["residual"] += move_line["amount_residual"]
|
||||
return total_amount
|
||||
|
||||
@api.multi
|
||||
def _get_report_values(self, docids, data):
|
||||
wizard_id = data["wizard_id"]
|
||||
company = self.env["res.company"].browse(data["company_id"])
|
||||
|
||||
@@ -7,6 +7,7 @@ from odoo import _, models
|
||||
|
||||
class OpenItemsXslx(models.AbstractModel):
|
||||
_name = "report.a_f_r.report_open_items_xlsx"
|
||||
_description = "Open Items XLSX Report"
|
||||
_inherit = "report.account_financial_report.abstract_report_xlsx"
|
||||
|
||||
def _get_report_name(self, report, data=False):
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
from natsort import natsorted
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class TrialBalanceReport(models.AbstractModel):
|
||||
_name = "report.account_financial_report.trial_balance"
|
||||
_description = "Trial Balance Report"
|
||||
|
||||
@api.model
|
||||
def get_html(self, given_context=None):
|
||||
@@ -203,6 +202,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||
pl_initial_currency_balance += initial_balance["amount_currency"]
|
||||
return pl_initial_balance, pl_initial_currency_balance
|
||||
|
||||
# flake8: noqa: C901
|
||||
def _get_data(
|
||||
self,
|
||||
account_ids,
|
||||
@@ -343,7 +343,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||
prt_id = tb["partner_id"][0]
|
||||
if tb["partner_id"] not in partners_ids:
|
||||
partners_data.update(
|
||||
{prt_id: {"id": prt_id, "name": tb["partner_id"][1],}}
|
||||
{prt_id: {"id": prt_id, "name": tb["partner_id"][1]}}
|
||||
)
|
||||
total_amount[acc_id][prt_id] = {}
|
||||
total_amount[acc_id][prt_id]["credit"] = tb["credit"]
|
||||
@@ -363,7 +363,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||
prt_id = tb["partner_id"][0]
|
||||
if tb["partner_id"] not in partners_ids:
|
||||
partners_data.update(
|
||||
{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():
|
||||
total_amount[acc_id][prt_id] = {}
|
||||
@@ -620,7 +620,6 @@ class TrialBalanceReport(models.AbstractModel):
|
||||
] += total_amount[acc_id]["ending_currency_balance"]
|
||||
return groups_data
|
||||
|
||||
@api.multi
|
||||
def _get_report_values(self, docids, data):
|
||||
show_partner_details = data["show_partner_details"]
|
||||
wizard_id = data["wizard_id"]
|
||||
@@ -682,9 +681,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||
)
|
||||
trial_balance = list(groups_data.values())
|
||||
trial_balance += list(accounts_data.values())
|
||||
trial_balance = natsorted(
|
||||
trial_balance, key=itemgetter("complete_code", "code")
|
||||
)
|
||||
trial_balance = sorted(trial_balance, key=lambda k: k["complete_code"])
|
||||
for trial in trial_balance:
|
||||
counter = trial["complete_code"].count("/")
|
||||
trial["level"] = counter
|
||||
@@ -694,10 +691,10 @@ class TrialBalanceReport(models.AbstractModel):
|
||||
)
|
||||
trial_balance = list(groups_data.values())
|
||||
trial_balance += list(accounts_data.values())
|
||||
trial_balance = natsorted(trial_balance, key=itemgetter("code"))
|
||||
trial_balance = sorted(trial_balance, key=lambda k: k["code"])
|
||||
if hierarchy_on == "none":
|
||||
trial_balance = list(accounts_data.values())
|
||||
trial_balance = natsorted(trial_balance, key=itemgetter("code"))
|
||||
trial_balance = sorted(trial_balance, key=lambda k: k["code"])
|
||||
else:
|
||||
if foreign_currency:
|
||||
for account_id in accounts_data.keys():
|
||||
|
||||
@@ -8,6 +8,7 @@ from odoo import _, models
|
||||
|
||||
class TrialBalanceXslx(models.AbstractModel):
|
||||
_name = "report.a_f_r.report_trial_balance_xlsx"
|
||||
_description = "Trial Balance XLSX Report"
|
||||
_inherit = "report.account_financial_report.abstract_report_xlsx"
|
||||
|
||||
def _get_report_name(self, report, data=False):
|
||||
|
||||
@@ -7,6 +7,7 @@ from odoo import api, models
|
||||
|
||||
class VATReport(models.AbstractModel):
|
||||
_name = "report.account_financial_report.vat_report"
|
||||
_description = "Vat Report Report"
|
||||
|
||||
def _get_tax_data(self, tax_ids):
|
||||
taxes = self.env["account.tax"].browse(tax_ids)
|
||||
@@ -18,7 +19,6 @@ class VATReport(models.AbstractModel):
|
||||
"id": tax.id,
|
||||
"name": tax.name,
|
||||
"tax_group_id": tax.tax_group_id.id,
|
||||
"tags_ids": tax.tag_ids.ids,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -42,15 +42,19 @@ class VATReport(models.AbstractModel):
|
||||
"tax_base_amount",
|
||||
"balance",
|
||||
"tax_line_id",
|
||||
"tax_repartition_line_id",
|
||||
"analytic_tag_ids",
|
||||
]
|
||||
tax_move_lines = self.env["account.move.line"].search_read(
|
||||
domain=domain, fields=ml_fields,
|
||||
domain=domain, fields=ml_fields
|
||||
)
|
||||
vat_data = {}
|
||||
tax_ids = set()
|
||||
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]
|
||||
)
|
||||
vat_data[tax_ml_id] = {}
|
||||
vat_data[tax_ml_id].update(
|
||||
{
|
||||
@@ -60,6 +64,7 @@ class VATReport(models.AbstractModel):
|
||||
if tax_move_line["balance"] > 0
|
||||
else (-1) * 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])
|
||||
@@ -90,11 +95,11 @@ class VATReport(models.AbstractModel):
|
||||
vat_report[tax_group_id] = {}
|
||||
vat_report[tax_group_id]["net"] = 0.0
|
||||
vat_report[tax_group_id]["tax"] = 0.0
|
||||
vat_report[tax_group_id][tax_id] = tax_data[tax_id]
|
||||
vat_report[tax_group_id][tax_id] = dict(tax_data[tax_id])
|
||||
vat_report[tax_group_id][tax_id].update({"net": 0.0, "tax": 0.0})
|
||||
else:
|
||||
if tax_id not in vat_report[tax_group_id].keys():
|
||||
vat_report[tax_group_id][tax_id] = tax_data[tax_id]
|
||||
vat_report[tax_group_id][tax_id] = dict(tax_data[tax_id])
|
||||
vat_report[tax_group_id][tax_id].update({"net": 0.0, "tax": 0.0})
|
||||
vat_report[tax_group_id]["net"] += tax_move_line["net"]
|
||||
vat_report[tax_group_id]["tax"] += tax_move_line["tax"]
|
||||
@@ -126,18 +131,18 @@ class VATReport(models.AbstractModel):
|
||||
vat_report = {}
|
||||
for tax_move_line in vat_report_data.values():
|
||||
tax_id = tax_move_line["tax_line_id"][0]
|
||||
tags_ids = tax_data[tax_id]["tags_ids"]
|
||||
tags_ids = tax_move_line["tags_ids"]
|
||||
if tags_ids:
|
||||
for tag_id in tags_ids:
|
||||
if tag_id not in vat_report.keys():
|
||||
vat_report[tag_id] = {}
|
||||
vat_report[tag_id]["net"] = 0.0
|
||||
vat_report[tag_id]["tax"] = 0.0
|
||||
vat_report[tag_id][tax_id] = tax_data[tax_id]
|
||||
vat_report[tag_id][tax_id] = dict(tax_data[tax_id])
|
||||
vat_report[tag_id][tax_id].update({"net": 0.0, "tax": 0.0})
|
||||
else:
|
||||
if tax_id not in vat_report[tag_id].keys():
|
||||
vat_report[tag_id][tax_id] = tax_data[tax_id]
|
||||
vat_report[tag_id][tax_id] = dict(tax_data[tax_id])
|
||||
vat_report[tag_id][tax_id].update({"net": 0.0, "tax": 0.0})
|
||||
vat_report[tag_id][tax_id]["net"] += tax_move_line["net"]
|
||||
vat_report[tag_id][tax_id]["tax"] += tax_move_line["tax"]
|
||||
@@ -156,7 +161,6 @@ class VATReport(models.AbstractModel):
|
||||
vat_report_list.append(vat_report[tag_id])
|
||||
return vat_report_list
|
||||
|
||||
@api.multi
|
||||
def _get_report_values(self, docids, data):
|
||||
wizard_id = data["wizard_id"]
|
||||
company = self.env["res.company"].browse(data["company_id"])
|
||||
|
||||
@@ -6,6 +6,7 @@ from odoo import _, models
|
||||
|
||||
class VATReportXslx(models.AbstractModel):
|
||||
_name = "report.a_f_r.report_vat_report_xlsx"
|
||||
_description = "Vat Report XLSX Report"
|
||||
_inherit = "report.account_financial_report.abstract_report_xlsx"
|
||||
|
||||
def _get_report_name(self, report, data):
|
||||
|
||||
Reference in New Issue
Block a user