feat: Apply decimal formatting to purchase dashboard, list view aggregates, and pivot view cells.

This commit is contained in:
Suherdy Yacob 2026-01-06 14:44:28 +07:00
parent 32e1114316
commit a8ce87fe25
9 changed files with 54 additions and 0 deletions

0
__init__.py Normal file
View File

View File

@ -17,6 +17,9 @@
'web_decimal_style/static/src/views/fields/formatters_patch.js', 'web_decimal_style/static/src/views/fields/formatters_patch.js',
'web_decimal_style/static/src/views/fields/float_field.xml', 'web_decimal_style/static/src/views/fields/float_field.xml',
'web_decimal_style/static/src/views/fields/monetary_field.xml', 'web_decimal_style/static/src/views/fields/monetary_field.xml',
'web_decimal_style/static/src/views/purchase_dashboard.xml',
'web_decimal_style/static/src/views/purchase_dashboard_patch.js',
'web_decimal_style/static/src/views/list_pivot_patch.xml',
], ],
'web.assets_frontend': [ 'web.assets_frontend': [
'web_decimal_style/static/src/css/decimal_style.css', 'web_decimal_style/static/src/css/decimal_style.css',
@ -24,6 +27,7 @@
'web_decimal_style/static/src/views/fields/formatters_patch.js', 'web_decimal_style/static/src/views/fields/formatters_patch.js',
'web_decimal_style/static/src/views/fields/float_field.xml', 'web_decimal_style/static/src/views/fields/float_field.xml',
'web_decimal_style/static/src/views/fields/monetary_field.xml', 'web_decimal_style/static/src/views/fields/monetary_field.xml',
'web_decimal_style/static/src/views/list_pivot_patch.xml',
], ],
}, },
'installable': True, 'installable': True,

Binary file not shown.

0
models/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<!-- Patch List View Footer Aggregates -->
<t t-inherit="web.ListRenderer" t-inherit-mode="extension">
<xpath expr="//tfoot//span[@t-esc='aggregate.value']" position="replace">
<span t-out="aggregate.value" t-att-data-tooltip="aggregate.help"/>
</xpath>
</t>
<!-- Patch List View Group Row Aggregates -->
<t t-inherit="web.ListRenderer.GroupRow" t-inherit-mode="extension">
<xpath expr="//t[@t-esc='formatAggregateValue(group, column)']" position="replace">
<t t-if="column.type === 'field'" t-out="formatAggregateValue(group, column)"/>
</xpath>
</t>
<!-- Patch Pivot View Cells -->
<t t-inherit="web.PivotRenderer" t-inherit-mode="extension">
<xpath expr="//div[hasclass('o_variation')]" position="attributes">
<attribute name="t-esc"></attribute>
<attribute name="t-out">getFormattedVariation(cell)</attribute>
</xpath>
<xpath expr="//div[hasclass('o_value')]" position="attributes">
<attribute name="t-esc"></attribute>
<attribute name="t-out">getFormattedValue(cell)</attribute>
</xpath>
</t>
</templates>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="web_decimal_style.PurchaseDashboard" t-inherit="purchase.PurchaseDashboard" t-inherit-mode="extension">
<xpath expr="//t[@t-out=&quot;purchaseData['all_avg_order_value']&quot;]" position="replace">
<t t-out="formatDecimal(purchaseData['all_avg_order_value'])"/>
</xpath>
<xpath expr="//t[@t-out=&quot;purchaseData['all_total_last_7_days']&quot;]" position="replace">
<t t-out="formatDecimal(purchaseData['all_total_last_7_days'])"/>
</xpath>
</t>
</templates>

View File

@ -0,0 +1,11 @@
/** @odoo-module **/
import { PurchaseDashBoard } from "@purchase/views/purchase_dashboard";
import { patch } from "@web/core/utils/patch";
import { wrapDecimal } from "@web_decimal_style/core/utils/numbers_patch";
patch(PurchaseDashBoard.prototype, {
formatDecimal(value) {
return wrapDecimal(value);
}
});