Merge PR #1037 into 16.0

Signed-off-by rafaelbn
pull/1041/head
OCA-git-bot 2023-04-28 10:24:54 +00:00
commit 6920352906
9 changed files with 121 additions and 107 deletions

View File

@ -43,12 +43,9 @@
],
"assets": {
"web.assets_backend": [
"account_financial_report/static/src/js/report_action.esm.js",
"account_financial_report/static/src/js/*",
"account_financial_report/static/src/xml/**/*",
],
"web.report_assets_common": [
"account_financial_report/static/src/js/report.js",
],
},
"installable": True,
"application": True,

View File

@ -325,7 +325,7 @@
res-model="account.move.line"
>
<t
t-raw="account_or_group_item_object['init_bal']['bal_curr']"
t-out="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</span>
@ -338,7 +338,7 @@
res-model="account.move.line"
>
<t
t-raw="account_or_group_item_object['init_bal']['bal_curr']"
t-out="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</span>
@ -724,7 +724,7 @@
style="color: black;"
>
<t
t-raw="account_or_group_item_object['fin_bal']['bal_curr']"
t-out="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</a>
@ -741,7 +741,7 @@
style="color: black;"
>
<t
t-raw="account_or_group_item_object['fin_bal']['bal_curr']"
t-out="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</a>

View File

@ -17,9 +17,9 @@
<t t-set="display_account_name" t-value="with_account_name" />
<t t-set="title">
Journal Ledger -
<t t-raw="company_name" />
<t t-out="company_name" />
-
<t t-raw="currency_name" />
<t t-out="currency_name" />
</t>
<t t-set="company_name" t-value="Company_Name" />
<div class="page">

View File

@ -15,9 +15,9 @@
<!-- Defines global variables used by internal layout -->
<t t-set="title">
Open Items -
<t t-raw="company_name" />
<t t-out="company_name" />
-
<t t-raw="currency_name" />
<t t-out="currency_name" />
</t>
<t t-set="company_name" t-value="Company_Name" />
<div class="page">
@ -174,7 +174,7 @@
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<span t-raw="line['date'].strftime('%d/%m/%Y')" />
<span t-out="line['date'].strftime('%d/%m/%Y')" />
</div>
<!--## move-->
<div class="act_as_cell left">

View File

@ -18,9 +18,9 @@
<!-- Defines global variables used by internal layout -->
<t t-set="title">
Trial Balance -
<t t-raw="company_name" />
<t t-out="company_name" />
-
<t t-raw="currency_name" />
<t t-out="currency_name" />
</t>
<t t-set="company_name" t-value="Company_Name" />
<!-- <t t-set="res_company" t-value="company_id"/>-->
@ -92,8 +92,8 @@
view-type="form"
>
<t
t-raw="accounts_data[account_id]['code']"
/> - <t t-raw="accounts_data[account_id]['name']" />
t-out="accounts_data[account_id]['code']"
/> - <t t-out="accounts_data[account_id]['name']" />
</span>
</div>
<div class="act_as_table data_table" style="width: 100%;">
@ -242,7 +242,7 @@
res-model="account.group"
view-type="form"
>
<t t-raw="balance['code']" />
<t t-out="balance['code']" />
</span>
</div>
<div class="act_as_cell left" t-att-style="style">
@ -299,7 +299,7 @@
res-model="account.move.line"
>
<t
t-raw="balance['initial_balance']"
t-out="balance['initial_balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -317,7 +317,7 @@
res-model="account.move.line"
>
<t
t-raw="total_amount[account_id][partner_id]['initial_balance']"
t-out="total_amount[account_id][partner_id]['initial_balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -357,7 +357,7 @@
res-model="account.move.line"
>
<t
t-raw="balance['debit']"
t-out="balance['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -377,7 +377,7 @@
res-model="account.move.line"
>
<t
t-raw="total_amount[account_id][partner_id]['debit']"
t-out="total_amount[account_id][partner_id]['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -417,7 +417,7 @@
res-model="account.move.line"
>
<t
t-raw="balance['credit']"
t-out="balance['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -437,7 +437,7 @@
res-model="account.move.line"
>
<t
t-raw="total_amount[account_id][partner_id]['credit']"
t-out="total_amount[account_id][partner_id]['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -476,7 +476,7 @@
res-model="account.move.line"
>
<t
t-raw="balance['balance']"
t-out="balance['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -496,7 +496,7 @@
res-model="account.move.line"
>
<t
t-raw="total_amount[account_id][partner_id]['balance']"
t-out="total_amount[account_id][partner_id]['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -531,7 +531,7 @@
res-model="account.move.line"
>
<t
t-raw="balance['ending_balance']"
t-out="balance['ending_balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -582,7 +582,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="line.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="line.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>-->
<!-- </span>-->
<!-- </t>-->
</div>
@ -603,7 +603,7 @@
res-model="account.move.line"
>
<t
t-raw="total_amount[account_id][partner_id]['initial_currency_balance']"
t-out="total_amount[account_id][partner_id]['initial_currency_balance']"
t-options="{'widget': 'monetary', 'display_currency': total_amount[account_id]['currency_id']}"
/>
</span>
@ -625,7 +625,7 @@
res-model="account.move.line"
>
<t
t-raw="balance['ending_currency_balance']"
t-out="balance['ending_currency_balance']"
t-options="{'widget': 'monetary', 'display_currency': balance['currency_id']}"
/>
</span>
@ -637,7 +637,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="line.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="line.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>-->
<!-- </span>-->
<!-- </t>-->
</div>
@ -658,7 +658,7 @@
res-model="account.move.line"
>
<t
t-raw="total_amount[account_id][partner_id]['ending_currency_balance']"
t-out="total_amount[account_id][partner_id]['ending_currency_balance']"
t-options="{'widget': 'monetary', 'display_currency': total_amount[account_id]['currency_id']}"
/>
</span>
@ -702,7 +702,7 @@
<!-- t-att-data-res-model="res_model"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="account.code"/> - <t t-att-style="style" t-raw="account.name"/></a>-->
<!-- <t t-att-style="style" t-out="account.code"/> - <t t-att-style="style" t-out="account.name"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- &lt;!&ndash;## Initial balance&ndash;&gt;-->
@ -715,7 +715,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="account.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- &lt;!&ndash;## Debit&ndash;&gt;-->
@ -730,7 +730,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="account.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- &lt;!&ndash;## Credit&ndash;&gt;-->
@ -745,7 +745,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="account.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- &lt;!&ndash;## Period Balance &ndash;&gt;-->
@ -760,7 +760,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="account.period_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.period_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- &lt;!&ndash;## Ending balance&ndash;&gt;-->
@ -772,7 +772,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style" >-->
<!-- <t t-att-style="style" t-raw="account.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- <t t-if="foreign_currency">-->
@ -793,7 +793,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style">-->
<!-- <t t-att-style="style" t-raw="account.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- <div class="act_as_cell amount" style="width: 8.86%;">-->
@ -804,7 +804,7 @@
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_monetary_multi"-->
<!-- t-att-style="style" >-->
<!-- <t t-att-style="style" t-raw="account.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>-->
<!-- <t t-att-style="style" t-out="account.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>-->
<!-- </span>-->
<!-- </div>-->
<!-- </t>-->

View File

@ -12,9 +12,9 @@
<template id="account_financial_report.report_vat_report_base">
<t t-set="title">
VAT Report -
<t t-raw="company_name" />
<t t-out="company_name" />
-
<t t-raw="currency_name" />
<t t-out="currency_name" />
</t>
<t t-set="company_name" t-value="company_name" />
<div class="page">
@ -55,7 +55,7 @@
t-att-res-model="res_model"
view-type="form"
>
<t t-att-style="style" t-raw="tag_or_group['code']" />
<t t-att-style="style" t-out="tag_or_group['code']" />
</span>
</div>
<div
@ -67,20 +67,20 @@
t-att-res-model="res_model"
view-type="form"
>
<t t-att-style="style" t-raw="tag_or_group['name']" />
<t t-att-style="style" t-out="tag_or_group['name']" />
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<t
t-att-style="style"
t-raw="tag_or_group['net']"
t-out="tag_or_group['net']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<t
t-att-style="style"
t-raw="tag_or_group['tax']"
t-out="tag_or_group['tax']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
@ -98,7 +98,7 @@
t-att-res-model="res_model"
view-type="form"
>
<t t-att-style="style" t-raw="tax['name']" />
<t t-att-style="style" t-out="tax['name']" />
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
@ -114,7 +114,7 @@
>
<t
t-att-style="style"
t-raw="tax['net']"
t-out="tax['net']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -132,7 +132,7 @@
>
<t
t-att-style="style"
t-raw="tax['tax']"
t-out="tax['tax']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>

View File

@ -0,0 +1,73 @@
/** @odoo-module */
import {useComponent, useEffect} from "@odoo/owl";
function toTitleCase(str) {
return str
.replaceAll(".", " ")
.replace(
/\w\S*/g,
(txt) => `${txt.charAt(0).toUpperCase()}${txt.substr(1).toLowerCase()}`
);
}
function enrich(component, targetElement, selector, isIFrame = false) {
let doc = window.document;
let contentDocument = targetElement;
// If we are in an iframe, we need to take the right document
// both for the element and the doc
if (isIFrame) {
contentDocument = targetElement.contentDocument;
doc = contentDocument;
}
// If there are selector, we may have multiple blocks of code to enrich
const targets = [];
if (selector) {
targets.push(...contentDocument.querySelectorAll(selector));
} else {
targets.push(contentDocument);
}
// Search the elements with the selector, update them and bind an action.
for (const currentTarget of targets) {
const elementsToWrap = currentTarget.querySelectorAll("[res-model][domain]");
for (const element of elementsToWrap.values()) {
const wrapper = doc.createElement("a");
wrapper.setAttribute("href", "#");
wrapper.addEventListener("click", (ev) => {
ev.preventDefault();
component.env.services.action.doAction({
type: "ir.actions.act_window",
res_model: element.getAttribute("res-model"),
domain: element.getAttribute("domain"),
name: toTitleCase(element.getAttribute("res-model")),
views: [
[false, "list"],
[false, "form"],
],
});
});
element.parentNode.insertBefore(wrapper, element);
wrapper.appendChild(element);
}
}
}
export function useEnrichWithActionLinks(ref, selector = null) {
const comp = useComponent();
useEffect(
(element) => {
// If we get an iframe, we need to wait until everything is loaded
if (element.matches("iframe")) {
element.addEventListener("load", () =>
enrich(comp, element, selector, true)
);
} else {
enrich(comp, element, selector);
}
},
() => [ref.el]
);
}

View File

@ -1,58 +0,0 @@
odoo.define("account_financial_report.report", function (require) {
"use strict";
require("web.dom_ready");
const utils = require("report.utils");
if (window.self === window.top) {
return;
}
const web_base_url = $("html").attr("web-base-url");
const trusted_host = utils.get_host_from_url(web_base_url);
const trusted_protocol = utils.get_protocol_from_url(web_base_url);
const trusted_origin = utils.build_origin(trusted_protocol, trusted_host);
/**
* Convert a model name to a capitalized title style
* Example: account.mode.line --> Account Move Line
*
* @param {String} str
* @returns {String}
*/
function toTitleCase(str) {
return str
.replaceAll(".", " ")
.replace(
/\w\S*/g,
(txt) => `${txt.charAt(0).toUpperCase()}${txt.substr(1).toLowerCase()}`
);
}
// Allow sending commands to the webclient
// `do_action` command with domain
$("[res-model][domain]")
.wrap("<a/>")
.attr("href", "#")
.on("click", function (ev) {
ev.preventDefault();
const res_model = $(this).attr("res-model");
const action = {
type: "ir.actions.act_window",
res_model: res_model,
domain: $(this).attr("domain"),
name: toTitleCase(res_model),
views: [
[false, "list"],
[false, "form"],
],
};
window.parent.postMessage(
{
message: "report:do_action",
action: action,
},
trusted_origin
);
});
});

View File

@ -1,6 +1,7 @@
/** @odoo-module **/
import {ReportAction} from "@web/webclient/actions/reports/report_action";
import {patch} from "web.utils";
import {useEnrichWithActionLinks} from "./report.esm";
const MODULE_NAME = "account_financial_report";
@ -10,6 +11,7 @@ patch(ReportAction.prototype, "account_financial_report.ReportAction", {
this.isAccountFinancialReport = this.props.report_name.startsWith(
`${MODULE_NAME}.`
);
useEnrichWithActionLinks(this.iframe);
},
export() {