[IMP] project: allow clicking on Name of each row in profitability

This commit is contained in:
Xavier BOL (xbo)
2022-04-01 15:33:00 +02:00
committed by Laurent Stukkens (LTU)
parent 4006d6c9fb
commit b4abfd9ad3
2 changed files with 49 additions and 8 deletions
@@ -68,9 +68,24 @@ export default class ProjectRightPanel extends LegacyComponent {
async onProjectActionClick(event) {
event.stopPropagation();
let action = event.currentTarget.dataset.action;
const additionalContext = JSON.parse(event.currentTarget.dataset.additional_context || "{}");
if (event.currentTarget.dataset.type === "object") {
const dataset = event.currentTarget.dataset;
let action = dataset.action;
const additionalContext = JSON.parse(dataset.additional_context || "{}");
if (dataset.type === "object") {
const args = [this.project_id];
if (dataset.section) {
args.push(dataset.section);
}
if (dataset.domain) {
args.push(JSON.parse(dataset.domain || '[]'));
}
if (dataset.resId) {
args.push(Number(dataset.resId));
}
let context = {};
if (dataset.context) {
context = dataset.context;
}
action = await this.rpc({
// Use the call_button method in order to have an action
// with the correct view naming, i.e. list view is named
@@ -78,10 +93,10 @@ export default class ProjectRightPanel extends LegacyComponent {
route: '/web/dataset/call_button',
params: {
model: 'project.project',
method: event.currentTarget.dataset.action,
args: [this.project_id],
method: action,
args,
kwargs: {
context: this.context
context: Object.assign(this.context, context),
}
}
});
@@ -100,7 +100,20 @@
</thead>
<tbody>
<tr t-foreach="revenue_items" t-as="revenue" t-key="revenue.id" t-if="revenue.invoiced !== 0 || revenue.to_invoice !== 0">
<td><t t-esc="revenue.name"/></td>
<td>
<a t-if="revenue.action" class="o_rightpanel_button"
t-on-click="onProjectActionClick"
t-att-data-action="revenue.action.name"
t-att-data-type="revenue.action.type or 'action'"
t-att-data-domain="revenue.action.domain"
t-att-data-section="revenue.action.section"
t-att-data-res-id="revenue.action.res_id"
t-att-data-context="revenue.action.context"
>
<t t-esc="revenue.name"/>
</a>
<t t-esc="revenue.name" t-else=""/>
</td>
<td align="right" t-attf-class="{{ revenue.invoiced === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(revenue.invoiced)"/></td>
<td align="right" t-attf-class="{{ revenue.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(revenue.to_invoice)"/></td>
<td align="right" t-attf-class="{{ revenue.invoiced + revenue.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(revenue.invoiced + revenue.to_invoice)"/></td>
@@ -132,7 +145,20 @@
</thead>
<tbody>
<tr t-foreach="cost_items" t-as="cost" t-key="cost.id" t-if="cost.billed !== 0 || cost.to_bill !== 0">
<td><t t-esc="cost.name"/></td>
<td>
<a t-if="cost.action" class="o_rightpanel_button"
t-on-click="onProjectActionClick"
t-att-data-action="cost.action.name"
t-att-data-type="cost.action.type or 'action'"
t-att-data-domain="cost.action.domain"
t-att-data-section="cost.action.section"
t-att-data-res-id="cost.action.res_id"
t-att-data-context="cost.action.context"
>
<t t-esc="cost.name"/>
</a>
<t t-esc="cost.name" t-else=""/>
</td>
<td align="right" t-attf-class="{{ cost.billed === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(cost.billed)"/></td>
<td align="right" t-attf-class="{{ cost.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(cost.to_bill)"/></td>
<td align="right" t-attf-class="{{ cost.billed + cost.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(cost.billed + cost.to_bill)"/></td>