[IMP] project: add format monetary in project update components
This commit is contained in:
committed by
Laurent Stukkens (LTU)
parent
f13568c809
commit
3e721c28c4
@@ -728,6 +728,7 @@ class Project(models.Model):
|
||||
'user': self._get_user_values(),
|
||||
'milestones': self._get_milestones(),
|
||||
'buttons': sorted(self._get_stat_buttons(), key=lambda k: k['sequence']),
|
||||
'currency_id': self.currency_id.id,
|
||||
}
|
||||
if self._show_profitability():
|
||||
panel_data['profitability_items'] = self._get_profitability_items()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { AddMilestone, OpenMilestone } from '@project/js/right_panel/project_utils';
|
||||
import { formatFloat } from "@web/fields/formatters";
|
||||
import { formatFloat, formatMonetary } from "@web/fields/formatters";
|
||||
import { LegacyComponent } from "@web/legacy/legacy_component";
|
||||
import { session } from "@web/session";
|
||||
|
||||
const { onWillStart, onWillUpdateProps, useState } = owl;
|
||||
|
||||
@@ -32,6 +33,23 @@ export default class ProjectRightPanel extends LegacyComponent {
|
||||
return formatFloat(value, { digits: [false, 1] });
|
||||
}
|
||||
|
||||
formatMonetary(value, options = {}) {
|
||||
const valueFormatted = formatMonetary(value, {
|
||||
currencyId: this.state.data.currency_id,
|
||||
...options,
|
||||
'noSymbol': true,
|
||||
});
|
||||
const currency = session.currencies[this.state.data.currency_id];
|
||||
if (!currency) {
|
||||
return valueFormatted;
|
||||
}
|
||||
if (currency.position === "after") {
|
||||
return `${valueFormatted} ${currency.symbol}`;
|
||||
} else {
|
||||
return `${currency.symbol} ${valueFormatted}`;
|
||||
}
|
||||
}
|
||||
|
||||
async _loadQwebContext() {
|
||||
if (!this.project_id){ // If this is called from notif, multiples updates but no specific project
|
||||
return {};
|
||||
|
||||
@@ -101,17 +101,17 @@
|
||||
<tbody>
|
||||
<tr t-foreach="revenue_items" t-as="revenue" t-key="revenue.name">
|
||||
<td><t t-esc="revenue.name"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue.invoiced === 0 ? 'text-muted' : ''}}"><t t-esc="revenue.invoiced"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="revenue.to_invoice"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue.invoiced + revenue.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="revenue.invoiced + revenue.to_invoice"/></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>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>Total</td>
|
||||
<td align="right" t-attf-class="{{ revenue_total.invoiced === 0 ? 'text-muted' : ''}}"><t t-esc="revenue_total.invoiced"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue_total.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="revenue_total.to_invoice"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue_total.invoiced + revenue_total.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="revenue_total.invoiced + revenue_total.to_invoice"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue_total.invoiced === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(revenue_total.invoiced)"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue_total.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(revenue_total.to_invoice)"/></td>
|
||||
<td align="right" t-attf-class="{{ revenue_total.invoiced + revenue_total.to_invoice === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(revenue_total.invoiced + revenue_total.to_invoice)"/></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -133,17 +133,17 @@
|
||||
<tbody>
|
||||
<tr t-foreach="cost_items" t-as="cost" t-key="cost.name">
|
||||
<td><t t-esc="cost.name"/></td>
|
||||
<td align="right" t-attf-class="{{ cost.billed === 0 ? 'text-muted' : ''}}"><t t-esc="cost.billed"/></td>
|
||||
<td align="right" t-attf-class="{{ cost.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="cost.to_bill"/></td>
|
||||
<td align="right" t-attf-class="{{ cost.billed + cost.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="cost.billed + cost.to_bill"/></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>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>Total</td>
|
||||
<td align="right" t-attf-class="{{ cost_total.billed === 0 ? 'text-muted' : ''}}"><t t-esc="cost_total.billed"/></td>
|
||||
<td align="right" t-attf-class="{{ cost_total.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="cost_total.to_bill"/></td>
|
||||
<td align="right" t-attf-class="{{ cost_total.billed + cost_total.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="cost_total.billed + cost_total.to_bill"/></td>
|
||||
<td align="right" t-attf-class="{{ cost_total.billed === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(cost_total.billed)"/></td>
|
||||
<td align="right" t-attf-class="{{ cost_total.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(cost_total.to_bill)"/></td>
|
||||
<td align="right" t-attf-class="{{ cost_total.billed + cost_total.to_bill === 0 ? 'text-muted' : ''}}"><t t-esc="formatMonetary(cost_total.billed + cost_total.to_bill)"/></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -159,9 +159,9 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40%">Margin</th>
|
||||
<th style="width: 20%; text-align: right;" t-att-class="margin_invoiced_billed < 0 ? 'o_color_red' : 'o_color_green'"><t t-esc="margin_invoiced_billed"/></th>
|
||||
<th style="width: 20%; text-align: right;" t-att-class="margin_to_invoice_to_bill < 0 ? 'o_color_red' : 'o_color_green'"><t t-esc="margin_to_invoice_to_bill"/></th>
|
||||
<th style="width: 20%; text-align: right;" t-att-class="margin_total < 0 ? 'o_color_red' : 'o_color_green'"><t t-esc="margin_total"/></th>
|
||||
<th style="width: 20%; text-align: right;" t-att-class="margin_invoiced_billed < 0 ? 'o_color_red' : 'o_color_green'"><t t-esc="formatMonetary(margin_invoiced_billed)"/></th>
|
||||
<th style="width: 20%; text-align: right;" t-att-class="margin_to_invoice_to_bill < 0 ? 'o_color_red' : 'o_color_green'"><t t-esc="formatMonetary(margin_to_invoice_to_bill)"/></th>
|
||||
<th style="width: 20%; text-align: right;" t-att-class="margin_total < 0 ? 'o_color_red' : 'o_color_green'"><t t-esc="formatMonetary(margin_total)"/></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user