[MIG] account_financial_report: Migration to 15.0

pull/868/head
Jasmin Solanki 2022-03-16 17:30:32 +05:30
parent f681061d54
commit da42c86e1d
24 changed files with 116 additions and 145 deletions

View File

@ -6,7 +6,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Financial Reports",
"version": "14.0.2.0.1",
"version": "15.0.1.0.0",
"category": "Reporting",
"summary": "OCA Financial Reports",
"author": "Camptocamp SA,"
@ -34,7 +34,6 @@
"report/templates/trial_balance.xml",
"report/templates/vat_report.xml",
"view/account_view.xml",
"view/report_template.xml",
"view/report_general_ledger.xml",
"view/report_journal_ledger.xml",
"view/report_trial_balance.xml",
@ -42,7 +41,18 @@
"view/report_aged_partner_balance.xml",
"view/report_vat_report.xml",
],
"qweb": ["static/src/xml/report.xml"],
"assets": {
"web.assets_backend": [
"account_financial_report/static/src/js/action_manager_report.js",
"account_financial_report/static/src/js/client_action.js",
],
"web.report_assets_common": [
"account_financial_report/static/src/js/report.js"
],
"web.assets_qweb": [
"account_financial_report/static/src/xml/**/*",
],
},
"installable": True,
"application": True,
"auto_install": False,

View File

@ -1136,7 +1136,7 @@ msgstr "المستوى"
#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0
#, fuzzy, python-format
msgid "Level %s"
msgstr "المستوى"
msgstr "المستوى %s"
#. module: account_financial_report
#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0

View File

@ -7,7 +7,6 @@ class AccountAccount(models.Model):
_inherit = "account.account"
centralized = fields.Boolean(
"Centralized",
help="If flagged, no details will be displayed in "
"the General Ledger report (the webkit one only), "
"only centralized amounts per period.",

View File

@ -10,7 +10,7 @@ class AccountGroup(models.Model):
group_child_ids = fields.One2many(
comodel_name="account.group", inverse_name="parent_id", string="Child Groups"
)
level = fields.Integer(string="Level", compute="_compute_level")
level = fields.Integer(compute="_compute_level", recursive=True)
account_ids = fields.One2many(
comodel_name="account.account", inverse_name="group_id", string="Accounts"
)
@ -20,8 +20,12 @@ class AccountGroup(models.Model):
string="Compute accounts",
store=True,
)
complete_name = fields.Char("Full Name", compute="_compute_complete_name")
complete_code = fields.Char("Full Code", compute="_compute_complete_code")
complete_name = fields.Char(
"Full Name", compute="_compute_complete_name", recursive=True
)
complete_code = fields.Char(
"Full Code", compute="_compute_complete_code", recursive=True
)
@api.depends("name", "parent_id.complete_name")
def _compute_complete_name(self):

View File

@ -15,11 +15,11 @@ class IrActionsReport(models.Model):
@api.model
def _render_qweb_html(self, docids, data=None):
context = self._prepare_account_financial_report_context(data)
obj = self.with_context(context) if context else self
obj = self.with_context(**context) if context else self
return super(IrActionsReport, obj)._render_qweb_html(docids, data)
@api.model
def _render_xlsx(self, docids, data):
context = self._prepare_account_financial_report_context(data)
obj = self.with_context(context) if context else self
obj = self.with_context(**context) if context else self
return super(IrActionsReport, obj)._render_xlsx(docids, data)

View File

@ -40,7 +40,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
3: {
"header": _(u"Age ≤ 30 d."),
"header": _("Age ≤ 30 d."),
"field": "30_days",
"field_footer_total": "30_days",
"field_footer_percent": "percent_30_days",
@ -48,7 +48,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
4: {
"header": _(u"Age ≤ 60 d."),
"header": _("Age ≤ 60 d."),
"field": "60_days",
"field_footer_total": "60_days",
"field_footer_percent": "percent_60_days",
@ -56,7 +56,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
5: {
"header": _(u"Age ≤ 90 d."),
"header": _("Age ≤ 90 d."),
"field": "90_days",
"field_footer_total": "90_days",
"field_footer_percent": "percent_90_days",
@ -64,7 +64,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
6: {
"header": _(u"Age ≤ 120 d."),
"header": _("Age ≤ 120 d."),
"field": "120_days",
"field_footer_total": "120_days",
"field_footer_percent": "percent_120_days",
@ -106,7 +106,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
9: {
"header": _(u"Age ≤ 30 d."),
"header": _("Age ≤ 30 d."),
"field": "30_days",
"field_footer_total": "30_days",
"field_footer_percent": "percent_30_days",
@ -115,7 +115,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
10: {
"header": _(u"Age ≤ 60 d."),
"header": _("Age ≤ 60 d."),
"field": "60_days",
"field_footer_total": "60_days",
"field_footer_percent": "percent_60_days",
@ -124,7 +124,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
11: {
"header": _(u"Age ≤ 90 d."),
"header": _("Age ≤ 90 d."),
"field": "90_days",
"field_footer_total": "90_days",
"field_footer_percent": "percent_90_days",
@ -133,7 +133,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"width": 14,
},
12: {
"header": _(u"Age ≤ 120 d."),
"header": _("Age ≤ 120 d."),
"field": "120_days",
"field_footer_total": "120_days",
"field_footer_percent": "percent_120_days",
@ -282,7 +282,9 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
"""
name = None
label = _("Partner cumul aged balance")
super().write_ending_balance_from_dict(my_object, name, label, report_data)
return super().write_ending_balance_from_dict(
my_object, name, label, report_data
)
def write_account_footer_from_dict(
self,

View File

@ -97,7 +97,8 @@ class GeneralLedgerXslx(models.AbstractModel):
return [
[
_("Date range filter"),
_("From: %s To: %s") % (report.date_from, report.date_to),
_("From: %(date_from)s To: %(date_to)s")
% ({"date_from": report.date_from, "date_to": report.date_to}),
],
[
_("Target moves filter"),
@ -329,7 +330,7 @@ class GeneralLedgerXslx(models.AbstractModel):
label = _("Partner Initial balance")
elif "account" in my_object["type"]:
label = _("Initial balance")
super(GeneralLedgerXslx, self).write_initial_balance_from_dict(
return super(GeneralLedgerXslx, self).write_initial_balance_from_dict(
my_object, label, report_data
)
@ -341,6 +342,6 @@ class GeneralLedgerXslx(models.AbstractModel):
elif "account" in my_object["type"]:
name = my_object["code"] + " - " + my_object["name"]
label = _("Ending balance")
super(GeneralLedgerXslx, self).write_ending_balance_from_dict(
return super(GeneralLedgerXslx, self).write_ending_balance_from_dict(
my_object, name, label, report_data
)

View File

@ -86,11 +86,11 @@ class JournalLedgerReport(models.AbstractModel):
def _get_move_lines_order(self, move_ids, wizard, journal_ids):
return ""
def _get_move_lines_data(self, ml, wizard, ml_taxes, auto_sequence):
def _get_move_lines_data(self, ml, wizard, ml_taxes, auto_sequence, exigible):
base_debit = (
base_credit
) = tax_debit = tax_credit = base_balance = tax_balance = 0.0
if ml.tax_exigible:
if exigible:
base_debit = ml_taxes and ml.debit or 0.0
base_credit = ml_taxes and ml.credit or 0.0
base_balance = ml_taxes and ml.balance or 0.0
@ -179,6 +179,10 @@ class JournalLedgerReport(models.AbstractModel):
self._get_move_lines_domain(move_ids, wizard, journal_ids),
order=self._get_move_lines_order(move_ids, wizard, journal_ids),
)
move_lines_exigible = self.env["account.move.line"].search(
self._get_move_lines_domain(move_ids, wizard, journal_ids)
+ self.env["account.move.line"]._get_tax_exigible_domain(),
)
move_line_ids_taxes_data = {}
if move_lines:
# Get the taxes ids for the move lines
@ -221,8 +225,9 @@ class JournalLedgerReport(models.AbstractModel):
and move_line_ids_taxes_data[ml.id]
or {}
)
exigible = ml in move_lines_exigible
Move_Lines[ml.move_id.id].append(
self._get_move_lines_data(ml, wizard, taxes, auto_sequence)
self._get_move_lines_data(ml, wizard, taxes, auto_sequence, exigible)
)
account_ids_data = self._get_account_data(accounts)
partner_ids_data = self._get_partner_data(partners)

View File

@ -134,7 +134,8 @@ class JournalLedgerXslx(models.AbstractModel):
[_("Company"), report.company_id.name],
[
_("Date range filter"),
_("From: %s To: %s") % (report.date_from, report.date_to),
_("From: %(date_from)s To: %(date_to)s")
% ({"date_from": report.date_from, "date_to": report.date_to}),
],
[
_("Target moves filter"),

View File

@ -211,6 +211,6 @@ class OpenItemsXslx(models.AbstractModel):
name = my_object["code"] + " - " + my_object["name"]
my_object["residual"] = total_amount[account_id]["residual"]
label = _("Ending balance")
super(OpenItemsXslx, self).write_ending_balance_from_dict(
return super(OpenItemsXslx, self).write_ending_balance_from_dict(
my_object, name, label, report_data
)

View File

@ -17,9 +17,9 @@
<!-- Defines global variables used by internal layout -->
<t t-set="title">
Aged Partner Balance -
<t t-raw="company_name" />
<t t-out="company_name" />
-
<t t-raw="currency_name" />
<t t-out="currency_name" />
</t>
<div class="page">
<div class="row">
@ -264,7 +264,7 @@
res-model="account.move"
view-type="form"
>
<t t-raw="line['entry']" />
<t t-out="line['entry']" />
</span>
</div>
<!--## journal-->
@ -274,7 +274,7 @@
res-model="account.journal"
view-type="form"
>
<t t-raw="line['journal']" />
<t t-out="line['journal']" />
</span>
</div>
<!--## account code-->
@ -284,7 +284,7 @@
res-model="account.account"
view-type="form"
>
<t t-raw="line['account']" />
<t t-out="line['account']" />
</span>
</div>
<!--## partner-->
@ -294,7 +294,7 @@
res-model="res.partner"
view-type="form"
>
<t t-raw="line['partner']" />
<t t-out="line['partner']" />
</span>
</div>
<!--## ref - label-->
@ -304,7 +304,7 @@
res-model="account.move.line"
view-type="form"
>
<t t-raw="line['ref_label']" />
<t t-out="line['ref_label']" />
</span>
</div>
<!--## date_due-->
@ -328,7 +328,7 @@
res-model="account.move.line"
>
<t
t-raw="line['residual']"
t-out="line['residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -347,7 +347,7 @@
res-model="account.move.line"
>
<t
t-raw="line['current']"
t-out="line['current']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -367,7 +367,7 @@
res-model="account.move.line"
>
<t
t-raw="line['30_days']"
t-out="line['30_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -387,7 +387,7 @@
res-model="account.move.line"
>
<t
t-raw="line['60_days']"
t-out="line['60_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -407,7 +407,7 @@
res-model="account.move.line"
>
<t
t-raw="line['90_days']"
t-out="line['90_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -427,7 +427,7 @@
res-model="account.move.line"
>
<t
t-raw="line['120_days']"
t-out="line['120_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -447,7 +447,7 @@
res-model="account.move.line"
>
<t
t-raw="line['older']"
t-out="line['older']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>

View File

@ -6,7 +6,7 @@
href="/account_financial_report/static/src/css/report.css"
rel="stylesheet"
/>
<t t-raw="0" />
<t t-out="0" />
</div>
<div class="footer">
<div class="row">

View File

@ -106,8 +106,7 @@
t-set="domain"
t-value="[('tax_ids', 'in', tax['id']),
('date', '&gt;=', date_from),
('date', '&lt;=', date_to),
('tax_exigible', '=', True)]"
('date', '&lt;=', date_to)]+request.env['account.move.line']._get_tax_exigible_domain()"
/>
<span
t-att-domain="domain"
@ -125,8 +124,7 @@
t-set="domain"
t-value="[('tax_line_id', '=', tax['id']),
('date', '&gt;=', date_from),
('date', '&lt;=', date_to),
('tax_exigible', '=', True)]"
('date', '&lt;=', date_to)]+request.env['account.move.line']._get_tax_exigible_domain()"
/>
<span
t-att-domain="domain"

View File

@ -144,7 +144,8 @@ class TrialBalanceXslx(models.AbstractModel):
return [
[
_("Date range filter"),
_("From: %s To: %s") % (report.date_from, report.date_to),
_("From: %(date_from)s To: %(date_to)s")
% ({"date_from": report.date_from, "date_to": report.date_to}),
],
[
_("Target moves filter"),
@ -162,7 +163,7 @@ class TrialBalanceXslx(models.AbstractModel):
],
[
_("Limit hierarchy levels"),
_("Level %s" % report.show_hierarchy_level)
_("Level %s") % (report.show_hierarchy_level)
if report.limit_hierarchy_level
else _("No limit"),
],
@ -277,7 +278,7 @@ class TrialBalanceXslx(models.AbstractModel):
line_object.currency_id = line_object.report_account_id.currency_id
elif type_object == "account":
line_object.currency_id = line_object.currency_id
super(TrialBalanceXslx, self).write_line(line_object, report_data)
return super(TrialBalanceXslx, self).write_line(line_object, report_data)
def write_account_footer(self, account, name_value, report_data):
"""Specific function to write account footer for Trial Balance"""

View File

@ -36,8 +36,7 @@ class VATReport(models.AbstractModel):
("date", ">=", date_from),
("date", "<=", date_to),
("tax_line_id", "!=", False),
("tax_exigible", "=", True),
]
] + self.env["account.move.line"]._get_tax_exigible_domain()
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
@ -50,8 +49,7 @@ class VATReport(models.AbstractModel):
("company_id", "=", company_id),
("date", ">=", date_from),
("date", "<=", date_to),
("tax_exigible", "=", True),
]
] + self.env["account.move.line"]._get_tax_exigible_domain()
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:

View File

@ -1,35 +1,37 @@
odoo.define("account_financial_report.ReportActionManager", function (require) {
"use strict";
const ActionManager = require("web.ActionManager");
require("web.ReportActionManager");
ActionManager.include({
/**
* @override
*/
_executeReportClientAction: function (action, options) {
const MODULE_NAME = "account_financial_report";
// When 'report_action' is called from the backend, Odoo hardcodes the action tag.
// We have to make a hack to use our own report controller.
if (action.report_name.startsWith(`${MODULE_NAME}.`)) {
const urls = this._makeReportUrls(action);
const clientActionOptions = _.extend({}, options, {
context: action.context,
data: action.data,
display_name: action.display_name,
name: action.name,
report_file: action.report_file,
report_name: action.report_name,
report_url: urls.html,
});
return this.doAction(
"account_financial_report.client_action",
clientActionOptions
);
}
return this._super.apply(this, arguments);
},
});
});
// Method is available here https://github.com/odoo/odoo/blob/15.0/addons/web/static/src/webclient/actions/action_service.js#L981
// TO DO: Check for implement this action inherit
// odoo.define("account_financial_report.ReportActionManager", function (require) {
// "use strict";
//
// const ActionManager = require("web.ActionManager");
// require("web.ReportActionManager");
//
// ActionManager.include({
// /**
// * @override
// */
// _executeReportClientAction: function (action, options) {
// const MODULE_NAME = "account_financial_report";
//
// // When 'report_action' is called from the backend, Odoo hardcodes the action tag.
// // We have to make a hack to use our own report controller.
// if (action.report_name.startsWith(`${MODULE_NAME}.`)) {
// const urls = this._makeReportUrls(action);
// const clientActionOptions = _.extend({}, options, {
// context: action.context,
// data: action.data,
// display_name: action.display_name,
// name: action.name,
// report_file: action.report_file,
// report_name: action.report_name,
// report_url: urls.html,
// });
// return this.doAction(
// "account_financial_report.client_action",
// clientActionOptions
// );
// }
// return this._super.apply(this, arguments);
// },
// });
// });

View File

@ -689,7 +689,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
"active_model": "res.partner",
}
wizard = self.env["general.ledger.report.wizard"].with_context(context)
wizard = self.env["general.ledger.report.wizard"].with_context(**context)
self.assertEqual(wizard._default_partners(), expected_list)
def test_validate_date(self):

View File

@ -24,5 +24,5 @@ class TestOpenItems(AccountTestInvoicingCommon):
"active_model": "res.partner",
}
wizard = self.env["open.items.report.wizard"].with_context(context)
wizard = self.env["open.items.report.wizard"].with_context(**context)
self.assertEqual(wizard._default_partners(), expected_list)

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="account_financial_report_assets_backend"
name="account_financial_report assets_backend"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/account_financial_report/static/src/js/action_manager_report.js"
/>
<script
type="text/javascript"
src="/account_financial_report/static/src/js/client_action.js"
/>
</xpath>
</template>
<template
id="account_financial_report_assets_common"
name="account_financial_report report_assets"
inherit_id="web.report_assets_common"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/account_financial_report/static/src/js/report.js"
/>
</xpath>
</template>
</odoo>

View File

@ -14,7 +14,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
_inherit = "account_financial_report_abstract_wizard"
date_at = fields.Date(required=True, default=fields.Date.context_today)
date_from = fields.Date(string="Date From")
date_from = fields.Date()
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
@ -34,12 +34,10 @@ class AgedPartnerBalanceWizard(models.TransientModel):
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)

View File

@ -43,9 +43,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
"If partners are filtered, "
"debits and credits totals will not match the trial balance.",
)
show_analytic_tags = fields.Boolean(
string="Show analytic tags",
)
show_analytic_tags = fields.Boolean()
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
partner_ids = fields.Many2many(
@ -63,9 +61,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
comodel_name="account.analytic.account", string="Filter cost centers"
)
not_only_one_unaffected_earnings_account = fields.Boolean(
readonly=True, string="Not only one unaffected earnings account"
)
not_only_one_unaffected_earnings_account = fields.Boolean(readonly=True)
foreign_currency = fields.Boolean(
string="Show foreign currency",
help="Display foreign currency for move lines, unless "
@ -75,16 +71,13 @@ class GeneralLedgerReportWizard(models.TransientModel):
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
show_partner_details = fields.Boolean(
string="Show Partner Details",
default=True,
)
show_cost_center = fields.Boolean(

View File

@ -14,7 +14,7 @@ class OpenItemsReportWizard(models.TransientModel):
_inherit = "account_financial_report_abstract_wizard"
date_at = fields.Date(required=True, default=fields.Date.context_today)
date_from = fields.Date(string="Date From")
date_from = fields.Date()
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
@ -50,17 +50,13 @@ class OpenItemsReportWizard(models.TransientModel):
default=lambda self: self._default_foreign_currency(),
)
show_partner_details = fields.Boolean(
string="Show Partner Details",
default=True,
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)

View File

@ -32,7 +32,6 @@ class TrialBalanceReportWizard(models.TransientModel):
("relation", "Child Accounts"),
("none", "No hierarchy"),
],
string="Hierarchy On",
required=True,
default="none",
help="""Computed Accounts: Use when the account group have codes
@ -62,9 +61,7 @@ class TrialBalanceReportWizard(models.TransientModel):
partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners")
journal_ids = fields.Many2many(comodel_name="account.journal")
not_only_one_unaffected_earnings_account = fields.Boolean(
readonly=True, string="Not only one unaffected earnings account"
)
not_only_one_unaffected_earnings_account = fields.Boolean(readonly=True)
foreign_currency = fields.Boolean(
string="Show foreign currency",
@ -74,12 +71,10 @@ class TrialBalanceReportWizard(models.TransientModel):
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)

View File

@ -15,7 +15,6 @@ class VATReportWizard(models.TransientModel):
date_to = fields.Date("End Date", required=True)
based_on = fields.Selection(
[("taxtags", "Tax Tags"), ("taxgroups", "Tax Groups")],
string="Based On",
required=True,
default="taxtags",
)