Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/odoo_relational.py +4 -2
- api/routes_odoo_tables.py +2 -1
- platform/aios_grid.py +2 -1
- platform/core/grid_events.py +17 -0
- platform/core/table_store.py +31 -13
- platform/harness/filter_sql.py +3 -2
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/src/customer-grid/ColumnMenu.tsx +10 -6
- web/src/customer-grid/aggregations.ts +17 -5
- web/src/customer-grid/cells.ts +3 -1
- web/src/customer-grid/display.ts +15 -9
- web/src/customer-grid/export.ts +6 -8
- web/src/customer-grid/types.ts +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "b9cf9ebba6",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
b9cf9ebba6
|
api/odoo_relational.py
CHANGED
|
@@ -226,7 +226,8 @@ def _audit_flag(value):
|
|
| 226 |
|
| 227 |
|
| 228 |
def _audit_pct(value):
|
| 229 |
-
|
|
|
|
| 230 |
|
| 231 |
|
| 232 |
_AUDIT_CASTS = {"text": _audit_text, "html": _audit_html, "date": lambda v: _as_date(v),
|
|
@@ -656,7 +657,8 @@ def audit_projection(entry):
|
|
| 656 |
if how in _AUDIT_AGENT_SQL:
|
| 657 |
return _AUDIT_AGENT_SQL[how].format(c=col), cast, ("account_invoice_line_agent", col)
|
| 658 |
if how == "pct":
|
| 659 |
-
|
|
|
|
| 660 |
return ref, cast, None
|
| 661 |
|
| 662 |
|
|
|
|
| 226 |
|
| 227 |
|
| 228 |
def _audit_pct(value):
|
| 229 |
+
# Never cut a real Odoo decimal: 10 places drops binary float noise only.
|
| 230 |
+
return "" if value is None else round(float(value), 10)
|
| 231 |
|
| 232 |
|
| 233 |
_AUDIT_CASTS = {"text": _audit_text, "html": _audit_html, "date": lambda v: _as_date(v),
|
|
|
|
| 657 |
if how in _AUDIT_AGENT_SQL:
|
| 658 |
return _AUDIT_AGENT_SQL[how].format(c=col), cast, ("account_invoice_line_agent", col)
|
| 659 |
if how == "pct":
|
| 660 |
+
# Never cut a real Odoo decimal: 10 places drops binary float noise only.
|
| 661 |
+
return f"ROUND({ref} * 100, 10)", cast, (alias, col)
|
| 662 |
return ref, cast, None
|
| 663 |
|
| 664 |
|
api/routes_odoo_tables.py
CHANGED
|
@@ -2246,7 +2246,8 @@ def _read_wall_columns(table_key, session, cur, spec, fields, nodes, st, trail=(
|
|
| 2246 |
f"AND NOT COALESCE(({value_ok}), FALSE))")
|
| 2247 |
expr = f"(SELECT {agg} FROM {source} WHERE {join})"
|
| 2248 |
if ftype == "currency":
|
| 2249 |
-
|
|
|
|
| 2250 |
good += f" AND (({expr}) IS NULL OR isfinite({expr}))"
|
| 2251 |
elif fn in ("arrayjoin", "arraycompact", "concatenate"):
|
| 2252 |
from automation_engine import ROLLUP_MAX_CHARS
|
|
|
|
| 2246 |
f"AND NOT COALESCE(({value_ok}), FALSE))")
|
| 2247 |
expr = f"(SELECT {agg} FROM {source} WHERE {join})"
|
| 2248 |
if ftype == "currency":
|
| 2249 |
+
# Never cut a real Odoo decimal: 10 places drops binary float noise only.
|
| 2250 |
+
expr = f"round(({expr}), 10)"
|
| 2251 |
good += f" AND (({expr}) IS NULL OR isfinite({expr}))"
|
| 2252 |
elif fn in ("arrayjoin", "arraycompact", "concatenate"):
|
| 2253 |
from automation_engine import ROLLUP_MAX_CHARS
|
platform/aios_grid.py
CHANGED
|
@@ -405,7 +405,8 @@ def _clean_rating_max(raw):
|
|
| 405 |
|
| 406 |
#: The field types a number-style display format may apply to. `formula` is here because its
|
| 407 |
#: RESULT is a number the client renders; `pct` already renders in points and takes decimals.
|
| 408 |
-
|
|
|
|
| 409 |
|
| 410 |
|
| 411 |
def _clean_format(raw, ftype):
|
|
|
|
| 405 |
|
| 406 |
#: The field types a number-style display format may apply to. `formula` is here because its
|
| 407 |
#: RESULT is a number the client renders; `pct` already renders in points and takes decimals.
|
| 408 |
+
#: `number` is an Odoo float column: its Decimals setting is display only, never the stored value.
|
| 409 |
+
_NUMBER_FORMAT_TYPES = {"int", "currency", "pct", "formula", "number"}
|
| 410 |
|
| 411 |
|
| 412 |
def _clean_format(raw, ftype):
|
platform/core/grid_events.py
CHANGED
|
@@ -82,6 +82,19 @@ _FIELD_ECHO_PROPS = ('label', 'type', 'note', 'options', 'colorCodeOptions',
|
|
| 82 |
# S76-T28: '' , 0 and false are real defaults, so this key compares by type.
|
| 83 |
'defaultValue')
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
class StoreUnavailable(RuntimeError):
|
| 87 |
"""The store is down AND the caller offered no durable fallback (HTTP adapter β 503).
|
|
@@ -2132,6 +2145,7 @@ def handle_one(event, ctx):
|
|
| 2132 |
# own definition doors.
|
| 2133 |
shared_prior = None
|
| 2134 |
shared_field = False
|
|
|
|
| 2135 |
shared_storage_key = None
|
| 2136 |
grant_topic = None
|
| 2137 |
spreadsheet_choice_created = False
|
|
@@ -2231,6 +2245,7 @@ def handle_one(event, ctx):
|
|
| 2231 |
field['format'] = fmt
|
| 2232 |
elif key in field_by_key and not key.startswith('custom_'):
|
| 2233 |
base = field_by_key[key]
|
|
|
|
| 2234 |
field = {**base, 'note': str(raw.get('note') or '')[:2000]}
|
| 2235 |
# β W29-T83 β THE COLUMN SUMMARY ON A SOURCE-BACKED COLUMN. This branch rebuilds the
|
| 2236 |
# accepted def from the CONTRACT and adds only what a user may override, and `agg` was
|
|
@@ -2568,6 +2583,8 @@ def handle_one(event, ctx):
|
|
| 2568 |
fresh_fields = (table_workspace(
|
| 2569 |
ctx, allowed_pids=allowed_pids, consume_corrections=False).get('fields') or {})
|
| 2570 |
durable_field = fresh_fields.get(key)
|
|
|
|
|
|
|
| 2571 |
if not isinstance(durable_field, dict) or not _field_echo_equal(durable_field, field):
|
| 2572 |
raise StoreUnavailable('The saved field definition could not be read back.')
|
| 2573 |
from core.if_field import project_fields
|
|
|
|
| 82 |
# S76-T28: '' , 0 and false are real defaults, so this key compares by type.
|
| 83 |
'defaultValue')
|
| 84 |
|
| 85 |
+
#: What a source column's stored override may hold; its read-back takes these from the store only.
|
| 86 |
+
_SOURCE_OVERRIDE_KEYS = ('note', 'format', 'agg', 'measure', 'options', 'recurrence')
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def _source_echo(accepted, durable):
|
| 90 |
+
"""A source column's durable definition: the contract's keys from `accepted`, overrides from the store.
|
| 91 |
+
|
| 92 |
+
A summary or a format may sit in the tenant-wide stratum alone, with no per-user row.
|
| 93 |
+
"""
|
| 94 |
+
if not isinstance(durable, dict):
|
| 95 |
+
return durable
|
| 96 |
+
return {**{k: v for k, v in accepted.items() if k not in _SOURCE_OVERRIDE_KEYS}, **durable}
|
| 97 |
+
|
| 98 |
|
| 99 |
class StoreUnavailable(RuntimeError):
|
| 100 |
"""The store is down AND the caller offered no durable fallback (HTTP adapter β 503).
|
|
|
|
| 2145 |
# own definition doors.
|
| 2146 |
shared_prior = None
|
| 2147 |
shared_field = False
|
| 2148 |
+
source_backed = False
|
| 2149 |
shared_storage_key = None
|
| 2150 |
grant_topic = None
|
| 2151 |
spreadsheet_choice_created = False
|
|
|
|
| 2245 |
field['format'] = fmt
|
| 2246 |
elif key in field_by_key and not key.startswith('custom_'):
|
| 2247 |
base = field_by_key[key]
|
| 2248 |
+
source_backed = True
|
| 2249 |
field = {**base, 'note': str(raw.get('note') or '')[:2000]}
|
| 2250 |
# β W29-T83 β THE COLUMN SUMMARY ON A SOURCE-BACKED COLUMN. This branch rebuilds the
|
| 2251 |
# accepted def from the CONTRACT and adds only what a user may override, and `agg` was
|
|
|
|
| 2583 |
fresh_fields = (table_workspace(
|
| 2584 |
ctx, allowed_pids=allowed_pids, consume_corrections=False).get('fields') or {})
|
| 2585 |
durable_field = fresh_fields.get(key)
|
| 2586 |
+
if source_backed:
|
| 2587 |
+
durable_field = _source_echo(field, durable_field)
|
| 2588 |
if not isinstance(durable_field, dict) or not _field_echo_equal(durable_field, field):
|
| 2589 |
raise StoreUnavailable('The saved field definition could not be read back.')
|
| 2590 |
from core.if_field import project_fields
|
platform/core/table_store.py
CHANGED
|
@@ -163,16 +163,15 @@ def purge_trash(bucket, now=None):
|
|
| 163 |
#: paints no totals row at all for the colleague (`showTotals` is false when no field carries an
|
| 164 |
#: `agg`), which is exactly "not showing at the bottom".
|
| 165 |
#:
|
| 166 |
-
#: β
|
| 167 |
-
#:
|
| 168 |
-
#:
|
| 169 |
-
#: the column MEANS, and two accounts disagreeing about it is the defect, not a preference.
|
| 170 |
#:
|
| 171 |
#: β IT LIVES IN THE `__shared__` MEMBER OF THIS SAME BUCKET rather than in
|
| 172 |
#: `core/shared_overlay.py`'s `<key>__shared` document, and the reason is transactional: a summary
|
| 173 |
#: is written by the same `save_field` call that writes the note beside it, and the two must land
|
| 174 |
#: or fail together. It is a field-only tenant-wide member; Views never use it after Wave 48.
|
| 175 |
-
SHARED_FIELD_KEYS = ('agg',)
|
| 176 |
|
| 177 |
|
| 178 |
class LegacySharedViewMigrationError(RuntimeError):
|
|
@@ -206,7 +205,7 @@ def assert_annotation_only(before, after):
|
|
| 206 |
makes it, on paper, a second writer of a tenant-wide field entry with rules of its own, which
|
| 207 |
is exactly the shape C3 forbids. In practice it cannot mint one: both callers derive their
|
| 208 |
payload from `split_shared`, which keeps only `SHARED_FIELD_KEYS`, so what lands is
|
| 209 |
-
`{'agg': ...}` and never a `label`, a `type` or a `createdBy`. But that was a property of two
|
| 210 |
callers rather than a guarantee of the door, and a property nothing checks is the next edit's
|
| 211 |
to delete. This turns it into a guarantee: whatever callback `_update` is handed, the entry it
|
| 212 |
leaves behind can only be a column SUMMARY.
|
|
@@ -226,7 +225,8 @@ def assert_annotation_only(before, after):
|
|
| 226 |
for name in entry if name not in SHARED_FIELD_KEYS})
|
| 227 |
if stray:
|
| 228 |
raise ValueError(
|
| 229 |
-
'table_store: the tenant-wide field stratum carries a column summary
|
|
|
|
| 230 |
'write adds ' + ', '.join(stray) + '. A column definition is created through '
|
| 231 |
'core.shared_overlay.mint_field, which requires a creator, a grant list and a '
|
| 232 |
'description.')
|
|
@@ -245,7 +245,13 @@ def split_shared(payload):
|
|
| 245 |
payload = dict(payload or {})
|
| 246 |
shared = {}
|
| 247 |
for key in SHARED_FIELD_KEYS:
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
if value:
|
| 250 |
shared[key] = value
|
| 251 |
return payload, shared
|
|
@@ -857,12 +863,22 @@ class TableStore:
|
|
| 857 |
# has NO per-user record for it, so a decorate-only pass would have left them with exactly
|
| 858 |
# the blank totals row the owner reported. `aios_grid.workspace_wire` reads `meta['agg']`
|
| 859 |
# off whatever is here, base column or custom one alike.
|
|
|
|
|
|
|
| 860 |
for key, shared in _shared_fields(data).items():
|
| 861 |
-
|
| 862 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 863 |
continue
|
| 864 |
entry = fields.get(key)
|
| 865 |
-
fields[key] = {**entry,
|
| 866 |
for key, ack in corrections.items():
|
| 867 |
field = fields.get(key)
|
| 868 |
accepted_label = str(ack.get('label') or '')[:120]
|
|
@@ -2232,8 +2248,10 @@ class TableStore:
|
|
| 2232 |
# any entry it finds as a live tenant-wide summary, so an `{'agg': ''}` husk would be
|
| 2233 |
# skipped today and become a resurrection hazard the moment the read grows a second
|
| 2234 |
# shared key. Absence is the only honest spelling of "nobody set one".
|
|
|
|
|
|
|
| 2235 |
if shared_write:
|
| 2236 |
-
shared_fields[key] =
|
| 2237 |
else:
|
| 2238 |
shared_fields.pop(key, None)
|
| 2239 |
|
|
@@ -2301,7 +2319,7 @@ class TableStore:
|
|
| 2301 |
|
| 2302 |
def _share(shared_fields):
|
| 2303 |
if shared_write:
|
| 2304 |
-
shared_fields[new_key] =
|
| 2305 |
else:
|
| 2306 |
shared_fields.pop(new_key, None)
|
| 2307 |
|
|
|
|
| 163 |
#: paints no totals row at all for the colleague (`showTotals` is false when no field carries an
|
| 164 |
#: `agg`), which is exactly "not showing at the bottom".
|
| 165 |
#:
|
| 166 |
+
#: β `agg` AND THE DISPLAY `format` ARE THE COLUMN'S, shared tenant-wide (owner 2026-10-30:
|
| 167 |
+
#: decimals persist for every viewer, a pre-set field included). Width, column order, the note
|
| 168 |
+
#: and every `custom_`/`measure_` definition stay per user.
|
|
|
|
| 169 |
#:
|
| 170 |
#: β IT LIVES IN THE `__shared__` MEMBER OF THIS SAME BUCKET rather than in
|
| 171 |
#: `core/shared_overlay.py`'s `<key>__shared` document, and the reason is transactional: a summary
|
| 172 |
#: is written by the same `save_field` call that writes the note beside it, and the two must land
|
| 173 |
#: or fail together. It is a field-only tenant-wide member; Views never use it after Wave 48.
|
| 174 |
+
SHARED_FIELD_KEYS = ('agg', 'format')
|
| 175 |
|
| 176 |
|
| 177 |
class LegacySharedViewMigrationError(RuntimeError):
|
|
|
|
| 205 |
makes it, on paper, a second writer of a tenant-wide field entry with rules of its own, which
|
| 206 |
is exactly the shape C3 forbids. In practice it cannot mint one: both callers derive their
|
| 207 |
payload from `split_shared`, which keeps only `SHARED_FIELD_KEYS`, so what lands is
|
| 208 |
+
`{'agg': ..., 'format': {...}}` and never a `label`, a `type` or a `createdBy`. But that was a property of two
|
| 209 |
callers rather than a guarantee of the door, and a property nothing checks is the next edit's
|
| 210 |
to delete. This turns it into a guarantee: whatever callback `_update` is handed, the entry it
|
| 211 |
leaves behind can only be a column SUMMARY.
|
|
|
|
| 225 |
for name in entry if name not in SHARED_FIELD_KEYS})
|
| 226 |
if stray:
|
| 227 |
raise ValueError(
|
| 228 |
+
'table_store: the tenant-wide field stratum carries a column summary and display '
|
| 229 |
+
'format only, and this '
|
| 230 |
'write adds ' + ', '.join(stray) + '. A column definition is created through '
|
| 231 |
'core.shared_overlay.mint_field, which requires a creator, a grant list and a '
|
| 232 |
'description.')
|
|
|
|
| 245 |
payload = dict(payload or {})
|
| 246 |
shared = {}
|
| 247 |
for key in SHARED_FIELD_KEYS:
|
| 248 |
+
raw = payload.pop(key, None)
|
| 249 |
+
if key == 'format':
|
| 250 |
+
# A display format is a dict of typed options; anything else is no format.
|
| 251 |
+
if isinstance(raw, dict) and raw:
|
| 252 |
+
shared[key] = dict(raw)
|
| 253 |
+
continue
|
| 254 |
+
value = str(raw or '').strip()
|
| 255 |
if value:
|
| 256 |
shared[key] = value
|
| 257 |
return payload, shared
|
|
|
|
| 863 |
# has NO per-user record for it, so a decorate-only pass would have left them with exactly
|
| 864 |
# the blank totals row the owner reported. `aios_grid.workspace_wire` reads `meta['agg']`
|
| 865 |
# off whatever is here, base column or custom one alike.
|
| 866 |
+
# A shared `format` outranks a legacy per-user one. A legacy per-user format with no
|
| 867 |
+
# shared one still shows for its own user.
|
| 868 |
for key, shared in _shared_fields(data).items():
|
| 869 |
+
if not isinstance(shared, dict):
|
| 870 |
+
continue
|
| 871 |
+
over = {}
|
| 872 |
+
agg = str(shared.get('agg') or '').strip()
|
| 873 |
+
if agg:
|
| 874 |
+
over['agg'] = agg
|
| 875 |
+
fmt = shared.get('format')
|
| 876 |
+
if isinstance(fmt, dict) and fmt:
|
| 877 |
+
over['format'] = dict(fmt)
|
| 878 |
+
if not over:
|
| 879 |
continue
|
| 880 |
entry = fields.get(key)
|
| 881 |
+
fields[key] = {**entry, **over} if isinstance(entry, dict) else over
|
| 882 |
for key, ack in corrections.items():
|
| 883 |
field = fields.get(key)
|
| 884 |
accepted_label = str(ack.get('label') or '')[:120]
|
|
|
|
| 2248 |
# any entry it finds as a live tenant-wide summary, so an `{'agg': ''}` husk would be
|
| 2249 |
# skipped today and become a resurrection hazard the moment the read grows a second
|
| 2250 |
# shared key. Absence is the only honest spelling of "nobody set one".
|
| 2251 |
+
# β REPLACE, never merge: a save that clears the format but keeps the summary must
|
| 2252 |
+
# drop the old shared format. The client and grid_events send the whole field.
|
| 2253 |
if shared_write:
|
| 2254 |
+
shared_fields[key] = dict(shared_write)
|
| 2255 |
else:
|
| 2256 |
shared_fields.pop(key, None)
|
| 2257 |
|
|
|
|
| 2319 |
|
| 2320 |
def _share(shared_fields):
|
| 2321 |
if shared_write:
|
| 2322 |
+
shared_fields[new_key] = dict(shared_write)
|
| 2323 |
else:
|
| 2324 |
shared_fields.pop(new_key, None)
|
| 2325 |
|
platform/harness/filter_sql.py
CHANGED
|
@@ -898,10 +898,11 @@ def aggregate_sql(spec, agg, p=None):
|
|
| 898 |
return (f"COUNT(DISTINCT CASE WHEN {_blank_sql(spec)} THEN NULL "
|
| 899 |
f"ELSE {group_sql(spec)} END)")
|
| 900 |
n = f"TRY_CAST({spec['sql']} AS DOUBLE)"
|
|
|
|
| 901 |
if agg == 'sum':
|
| 902 |
-
return f"
|
| 903 |
if agg == 'average':
|
| 904 |
-
return f"
|
| 905 |
if agg == 'min':
|
| 906 |
return f"MIN({n})"
|
| 907 |
if agg == 'max':
|
|
|
|
| 898 |
return (f"COUNT(DISTINCT CASE WHEN {_blank_sql(spec)} THEN NULL "
|
| 899 |
f"ELSE {group_sql(spec)} END)")
|
| 900 |
n = f"TRY_CAST({spec['sql']} AS DOUBLE)"
|
| 901 |
+
# A compensated sum: a naive float SUM over thousands of prices drifts past 15 digits.
|
| 902 |
if agg == 'sum':
|
| 903 |
+
return f"fsum({n})"
|
| 904 |
if agg == 'average':
|
| 905 |
+
return f"(fsum({n}) / NULLIF(COUNT({n}), 0))"
|
| 906 |
if agg == 'min':
|
| 907 |
return f"MIN({n})"
|
| 908 |
if agg == 'max':
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
672bfb8d5d5f73510156c19fa3f43231bc1d4adcc12d486831d562e9be8a4b62
|
web/src/customer-grid/ColumnMenu.tsx
CHANGED
|
@@ -3788,9 +3788,10 @@ export default function ColumnMenu({
|
|
| 3788 |
field.scope === "cohort" ? `${typeLineBase} Β· this cohort only` : typeLineBase;
|
| 3789 |
|
| 3790 |
/** Wave-5 item 10 β which format editor this field gets, if any. */
|
|
|
|
| 3791 |
const formatKind: "number" | "date" | null =
|
| 3792 |
field.type === "int" || field.type === "currency" || field.type === "formula" ||
|
| 3793 |
-
field.type === "pct" || field.type === "rollup"
|
| 3794 |
? "number"
|
| 3795 |
: field.type === "date" || field.type === "created_time" || field.type === "last_modified_time"
|
| 3796 |
? "date"
|
|
@@ -4930,7 +4931,8 @@ export default function ColumnMenu({
|
|
| 4930 |
))}
|
| 4931 |
</select>
|
| 4932 |
</label>
|
| 4933 |
-
{
|
|
|
|
| 4934 |
<label className="cg-radio-row" style={{ flexDirection: "row" }}>
|
| 4935 |
<input
|
| 4936 |
type="checkbox"
|
|
@@ -4953,13 +4955,13 @@ export default function ColumnMenu({
|
|
| 4953 |
<span>Thousands separator (12,345)</span>
|
| 4954 |
</label>
|
| 4955 |
<label>
|
| 4956 |
-
<span>
|
| 4957 |
<select
|
| 4958 |
className="cg-select"
|
| 4959 |
value={
|
| 4960 |
Number.isInteger(fmtDraft.decimals) ? String(fmtDraft.decimals) : ""
|
| 4961 |
}
|
| 4962 |
-
aria-label="
|
| 4963 |
onChange={(e) =>
|
| 4964 |
setFmtDraft((d) => {
|
| 4965 |
const next = { ...d };
|
|
@@ -4969,7 +4971,8 @@ export default function ColumnMenu({
|
|
| 4969 |
})
|
| 4970 |
}
|
| 4971 |
>
|
| 4972 |
-
|
|
|
|
| 4973 |
{[0, 1, 2, 3, 4].map((n) => (
|
| 4974 |
<option key={n} value={n}>
|
| 4975 |
{n}
|
|
@@ -5359,7 +5362,8 @@ export default function ColumnMenu({
|
|
| 5359 |
|
| 5360 |
{/* Group 2 β display format. Description now lives in Edit field directly below Name,
|
| 5361 |
so there is one definition editor instead of two nearby doors. */}
|
| 5362 |
-
{
|
|
|
|
| 5363 |
<button type="button" onClick={() => setPane("format")}>
|
| 5364 |
<MenuLabel icon="format" text="Field format" />
|
| 5365 |
</button>
|
|
|
|
| 3788 |
field.scope === "cohort" ? `${typeLineBase} Β· this cohort only` : typeLineBase;
|
| 3789 |
|
| 3790 |
/** Wave-5 item 10 β which format editor this field gets, if any. */
|
| 3791 |
+
// An Odoo float column arrives as type "number", outside FieldType, and is a number field.
|
| 3792 |
const formatKind: "number" | "date" | null =
|
| 3793 |
field.type === "int" || field.type === "currency" || field.type === "formula" ||
|
| 3794 |
+
field.type === "pct" || field.type === "rollup" || (field.type as string) === "number"
|
| 3795 |
? "number"
|
| 3796 |
: field.type === "date" || field.type === "created_time" || field.type === "last_modified_time"
|
| 3797 |
? "date"
|
|
|
|
| 4931 |
))}
|
| 4932 |
</select>
|
| 4933 |
</label>
|
| 4934 |
+
{/* Allow negative is a write policy, so a pre-set field never shows it. */}
|
| 4935 |
+
{!schemaLocked && (field.type === "int" || field.type === "currency" || field.type === "pct") && (
|
| 4936 |
<label className="cg-radio-row" style={{ flexDirection: "row" }}>
|
| 4937 |
<input
|
| 4938 |
type="checkbox"
|
|
|
|
| 4955 |
<span>Thousands separator (12,345)</span>
|
| 4956 |
</label>
|
| 4957 |
<label>
|
| 4958 |
+
<span>Decimals</span>
|
| 4959 |
<select
|
| 4960 |
className="cg-select"
|
| 4961 |
value={
|
| 4962 |
Number.isInteger(fmtDraft.decimals) ? String(fmtDraft.decimals) : ""
|
| 4963 |
}
|
| 4964 |
+
aria-label="Decimals"
|
| 4965 |
onChange={(e) =>
|
| 4966 |
setFmtDraft((d) => {
|
| 4967 |
const next = { ...d };
|
|
|
|
| 4971 |
})
|
| 4972 |
}
|
| 4973 |
>
|
| 4974 |
+
{/* No decimals key shows the full value; the setting never rounds stored data. */}
|
| 4975 |
+
<option value="">Full value</option>
|
| 4976 |
{[0, 1, 2, 3, 4].map((n) => (
|
| 4977 |
<option key={n} value={n}>
|
| 4978 |
{n}
|
|
|
|
| 5362 |
|
| 5363 |
{/* Group 2 β display format. Description now lives in Edit field directly below Name,
|
| 5364 |
so there is one definition editor instead of two nearby doors. */}
|
| 5365 |
+
{/* Field format is display only, so a pre-set column offers it too. */}
|
| 5366 |
+
{formatKind && (
|
| 5367 |
<button type="button" onClick={() => setPane("format")}>
|
| 5368 |
<MenuLabel icon="format" text="Field format" />
|
| 5369 |
</button>
|
web/src/customer-grid/aggregations.ts
CHANGED
|
@@ -200,7 +200,7 @@ export function summaryLabel(choice: SummaryChoice): string {
|
|
| 200 |
/**
|
| 201 |
* Fold every field carrying an `agg` over `rows`, formatted to match its column:
|
| 202 |
* currency -> "$" + toLocaleString | everything else -> toLocaleString
|
| 203 |
-
* Values
|
| 204 |
*
|
| 205 |
* β **BLANK, NEVER ZERO** (C7, and the codebase's standing law): a numeric fold over a set
|
| 206 |
* holding no numeric value at all returns nothing and the cell stays empty β `0` is a
|
|
@@ -222,9 +222,21 @@ export function summaryLabel(choice: SummaryChoice): string {
|
|
| 222 |
* both callers answer them before folding. The final `else` is `percentile` on purpose β it is
|
| 223 |
* the only remaining member, and a `switch` with an unreachable default would be a lie.
|
| 224 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
function foldNumeric(nums: number[], agg: SummaryAggName, p: number | undefined): number {
|
| 226 |
-
if (agg === "sum") return
|
| 227 |
-
if (agg === "average") return
|
| 228 |
if (agg === "median") return median([...nums].sort((a, b) => a - b));
|
| 229 |
if (agg === "min") return Math.min(...nums);
|
| 230 |
if (agg === "max") return Math.max(...nums);
|
|
@@ -317,7 +329,7 @@ export function computeAggs(
|
|
| 317 |
if (!isNumericFieldType(f.type)) continue;
|
| 318 |
const nums = numbersOf(rows, f.key);
|
| 319 |
if (!nums.length) continue; // blank, never zero
|
| 320 |
-
const clean =
|
| 321 |
// β W41-T40 (instruction 16) β A SUMMARY WEARS ITS COLUMN'S UNIT. `display.cellText` paints
|
| 322 |
// a `pct` cell as "12.5%", so a bare "37.5" in the footer under a column of percentages is a
|
| 323 |
// number whose unit the reader has to infer. One decimal, the SAME as the cell, so the total
|
|
@@ -511,5 +523,5 @@ export function formatServerAgg(
|
|
| 511 |
return formatShare(value, typeof whole === "number" ? whole : undefined);
|
| 512 |
if (choice.agg === "count" || choice.agg === "count_distinct")
|
| 513 |
return Math.round(value).toLocaleString();
|
| 514 |
-
return wearColumnUnit(field,
|
| 515 |
}
|
|
|
|
| 200 |
/**
|
| 201 |
* Fold every field carrying an `agg` over `rows`, formatted to match its column:
|
| 202 |
* currency -> "$" + toLocaleString | everything else -> toLocaleString
|
| 203 |
+
* Values drop float noise at 15 significant digits (1234.5600000001) and are never rounded.
|
| 204 |
*
|
| 205 |
* β **BLANK, NEVER ZERO** (C7, and the codebase's standing law): a numeric fold over a set
|
| 206 |
* holding no numeric value at all returns nothing and the cell stays empty β `0` is a
|
|
|
|
| 222 |
* both callers answer them before folding. The final `else` is `percentile` on purpose β it is
|
| 223 |
* the only remaining member, and a `switch` with an unreachable default would be a lie.
|
| 224 |
*/
|
| 225 |
+
/** Neumaier compensated sum: a naive float sum over thousands of prices drifts past 15 digits. */
|
| 226 |
+
function exactSum(nums: number[]): number {
|
| 227 |
+
let sum = 0;
|
| 228 |
+
let carry = 0;
|
| 229 |
+
for (const n of nums) {
|
| 230 |
+
const t = sum + n;
|
| 231 |
+
carry += Math.abs(sum) >= Math.abs(n) ? (sum - t) + n : (n - t) + sum;
|
| 232 |
+
sum = t;
|
| 233 |
+
}
|
| 234 |
+
return sum + carry;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
function foldNumeric(nums: number[], agg: SummaryAggName, p: number | undefined): number {
|
| 238 |
+
if (agg === "sum") return exactSum(nums);
|
| 239 |
+
if (agg === "average") return exactSum(nums) / nums.length;
|
| 240 |
if (agg === "median") return median([...nums].sort((a, b) => a - b));
|
| 241 |
if (agg === "min") return Math.min(...nums);
|
| 242 |
if (agg === "max") return Math.max(...nums);
|
|
|
|
| 329 |
if (!isNumericFieldType(f.type)) continue;
|
| 330 |
const nums = numbersOf(rows, f.key);
|
| 331 |
if (!nums.length) continue; // blank, never zero
|
| 332 |
+
const clean = Number(foldNumeric(nums, agg, choice.p).toPrecision(15)); // drop float noise only, never round
|
| 333 |
// β W41-T40 (instruction 16) β A SUMMARY WEARS ITS COLUMN'S UNIT. `display.cellText` paints
|
| 334 |
// a `pct` cell as "12.5%", so a bare "37.5" in the footer under a column of percentages is a
|
| 335 |
// number whose unit the reader has to infer. One decimal, the SAME as the cell, so the total
|
|
|
|
| 523 |
return formatShare(value, typeof whole === "number" ? whole : undefined);
|
| 524 |
if (choice.agg === "count" || choice.agg === "count_distinct")
|
| 525 |
return Math.round(value).toLocaleString();
|
| 526 |
+
return wearColumnUnit(field, Number(value.toPrecision(15))); // drop float noise only, never round
|
| 527 |
}
|
web/src/customer-grid/cells.ts
CHANGED
|
@@ -840,7 +840,9 @@ function baseCell(
|
|
| 840 |
return {
|
| 841 |
kind: GridCellKind.Text,
|
| 842 |
data: String(v ?? ""),
|
| 843 |
-
|
|
|
|
|
|
|
| 844 |
...ro,
|
| 845 |
};
|
| 846 |
}
|
|
|
|
| 840 |
return {
|
| 841 |
kind: GridCellKind.Text,
|
| 842 |
data: String(v ?? ""),
|
| 843 |
+
// An Odoo float column typed "number" shows its full value through numberText, like `int`.
|
| 844 |
+
displayData: (field.type as string) === "number" && !noNumber
|
| 845 |
+
? numberText(num(v), field.format) : String(v ?? ""),
|
| 846 |
...ro,
|
| 847 |
};
|
| 848 |
}
|
web/src/customer-grid/display.ts
CHANGED
|
@@ -258,10 +258,9 @@ export function checkboxOn(v: CellValue | boolean): boolean {
|
|
| 258 |
}
|
| 259 |
|
| 260 |
/**
|
| 261 |
-
* The shared number display.
|
| 262 |
-
*
|
| 263 |
-
*
|
| 264 |
-
* separators; `decimals` fixes 0..4 places.
|
| 265 |
*/
|
| 266 |
export function numberText(
|
| 267 |
v: number, fmt: FieldFormat | undefined, defaultCurrencySymbol: FieldFormat["currencySymbol"] = ""
|
|
@@ -274,13 +273,11 @@ export function numberText(
|
|
| 274 |
abs >= 1e9 ? [1e9, "B"] : abs >= 1e6 ? [1e6, "M"] : [1e3, "k"];
|
| 275 |
return prefix + (v / div).toFixed(1) + suffix;
|
| 276 |
}
|
| 277 |
-
const authored = fmt?.decimals !== undefined || fmt?.thousands !== undefined ||
|
| 278 |
-
fmt?.abbrev !== undefined;
|
| 279 |
const d =
|
| 280 |
fmt && Number.isInteger(fmt.decimals) && (fmt.decimals as number) >= 0 &&
|
| 281 |
(fmt.decimals as number) <= 4
|
| 282 |
? (fmt.decimals as number)
|
| 283 |
-
:
|
| 284 |
const thousands = fmt?.thousands !== false;
|
| 285 |
if (d != null)
|
| 286 |
return prefix + (thousands
|
|
@@ -289,7 +286,13 @@ export function numberText(
|
|
| 289 |
maximumFractionDigits: d,
|
| 290 |
})
|
| 291 |
: v.toFixed(d));
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
}
|
| 294 |
|
| 295 |
/**
|
|
@@ -552,7 +555,7 @@ function namedPairList(value: unknown): string | null {
|
|
| 552 |
// W37-T14 β the pricelists that really price this SKU today, each with its price.
|
| 553 |
if (every("pricelist", "unit_price"))
|
| 554 |
return rows
|
| 555 |
-
.map((r) => `${String(r.pricelist)} $
|
| 556 |
.join(" Β· ");
|
| 557 |
return null;
|
| 558 |
}
|
|
@@ -791,6 +794,9 @@ export function formatDisplay(field: Field, v: CellValue, share?: string): strin
|
|
| 791 |
/** The value alone, with no share and no mode β every branch below is exactly the text this
|
| 792 |
* function has returned since wave 5, moved behind `formatDisplay` rather than changed. */
|
| 793 |
function valueText(field: Field, v: CellValue): string {
|
|
|
|
|
|
|
|
|
|
| 794 |
switch (field.type) {
|
| 795 |
case "link": {
|
| 796 |
// Surfaces without a permitted target projection use the grid's anonymous count.
|
|
|
|
| 258 |
}
|
| 259 |
|
| 260 |
/**
|
| 261 |
+
* The shared number display. Without a chosen 0..4 `decimals` it never rounds: every decimal shows.
|
| 262 |
+
* `abbrev` wins over decimals when the magnitude calls for it (34.0M, one decimal, k/M/B);
|
| 263 |
+
* `thousands: false` drops the separators; `decimals` fixes 0..4 places.
|
|
|
|
| 264 |
*/
|
| 265 |
export function numberText(
|
| 266 |
v: number, fmt: FieldFormat | undefined, defaultCurrencySymbol: FieldFormat["currencySymbol"] = ""
|
|
|
|
| 273 |
abs >= 1e9 ? [1e9, "B"] : abs >= 1e6 ? [1e6, "M"] : [1e3, "k"];
|
| 274 |
return prefix + (v / div).toFixed(1) + suffix;
|
| 275 |
}
|
|
|
|
|
|
|
| 276 |
const d =
|
| 277 |
fmt && Number.isInteger(fmt.decimals) && (fmt.decimals as number) >= 0 &&
|
| 278 |
(fmt.decimals as number) <= 4
|
| 279 |
? (fmt.decimals as number)
|
| 280 |
+
: null;
|
| 281 |
const thousands = fmt?.thousands !== false;
|
| 282 |
if (d != null)
|
| 283 |
return prefix + (thousands
|
|
|
|
| 286 |
maximumFractionDigits: d,
|
| 287 |
})
|
| 288 |
: v.toFixed(d));
|
| 289 |
+
// No chosen decimals: drop binary noise at 15 significant digits only; money shows at least 2.
|
| 290 |
+
const clean = Number(v.toPrecision(15));
|
| 291 |
+
const money = Boolean(symbol || defaultCurrencySymbol);
|
| 292 |
+
const full = { minimumFractionDigits: money ? 2 : 0, maximumFractionDigits: 20 };
|
| 293 |
+
return prefix + (thousands
|
| 294 |
+
? clean.toLocaleString(undefined, full)
|
| 295 |
+
: clean.toLocaleString("en-US", { ...full, useGrouping: false }));
|
| 296 |
}
|
| 297 |
|
| 298 |
/**
|
|
|
|
| 555 |
// W37-T14 β the pricelists that really price this SKU today, each with its price.
|
| 556 |
if (every("pricelist", "unit_price"))
|
| 557 |
return rows
|
| 558 |
+
.map((r) => `${String(r.pricelist)} ${numberText(r.unit_price as number, undefined, "$")}`)
|
| 559 |
.join(" Β· ");
|
| 560 |
return null;
|
| 561 |
}
|
|
|
|
| 794 |
/** The value alone, with no share and no mode β every branch below is exactly the text this
|
| 795 |
* function has returned since wave 5, moved behind `formatDisplay` rather than changed. */
|
| 796 |
function valueText(field: Field, v: CellValue): string {
|
| 797 |
+
// An Odoo float column arrives typed "number" (outside FieldType): it reads like `int`.
|
| 798 |
+
if ((field.type as string) === "number")
|
| 799 |
+
return numericIsBlank(v) ? String(v ?? "") : numberText(num(v), field.format);
|
| 800 |
switch (field.type) {
|
| 801 |
case "link": {
|
| 802 |
// Surfaces without a permitted target projection use the grid's anonymous count.
|
web/src/customer-grid/export.ts
CHANGED
|
@@ -413,22 +413,20 @@ function excelSerial(d: Date, utc: boolean): number {
|
|
| 413 |
* abbreviated column reads in full here. Stated, not silent. */
|
| 414 |
function numFmtCode(f: Field): string | null {
|
| 415 |
const fmt = f.format;
|
| 416 |
-
const authored = fmt?.decimals !== undefined || fmt?.thousands !== undefined ||
|
| 417 |
-
fmt?.abbrev !== undefined;
|
| 418 |
const d =
|
| 419 |
fmt && Number.isInteger(fmt.decimals) && (fmt.decimals as number) >= 0 &&
|
| 420 |
-
(fmt.decimals as number) <= 4 ? (fmt.decimals as number) :
|
| 421 |
const grouped = fmt?.thousands !== false;
|
| 422 |
const dec = (n: number) => (n > 0 ? "." + "0".repeat(n) : "");
|
| 423 |
-
//
|
| 424 |
-
|
|
|
|
|
|
|
| 425 |
const numeric = d != null ? `${grouped ? "#,##0" : "0"}${dec(d)}`
|
| 426 |
-
: grouped ? "#,##0.###
|
| 427 |
// The stored magnitude already uses percent units. Quote the suffix so Excel cannot
|
| 428 |
// multiply it by 100; Field decimals and grouping still apply to the numeric portion.
|
| 429 |
if (f.type === "pct") return `${numeric}"%"`;
|
| 430 |
-
// S76-T29: the same symbol `numberText` paints, `$` only for a currency field naming none.
|
| 431 |
-
const symbol = fmt?.currencySymbol ?? (f.type === "currency" ? "$" : "");
|
| 432 |
if (symbol) return `"${symbol}${symbol === "$" ? "" : " "}"${numeric}`;
|
| 433 |
return numeric === "General" ? null : numeric;
|
| 434 |
}
|
|
|
|
| 413 |
* abbreviated column reads in full here. Stated, not silent. */
|
| 414 |
function numFmtCode(f: Field): string | null {
|
| 415 |
const fmt = f.format;
|
|
|
|
|
|
|
| 416 |
const d =
|
| 417 |
fmt && Number.isInteger(fmt.decimals) && (fmt.decimals as number) >= 0 &&
|
| 418 |
+
(fmt.decimals as number) <= 4 ? (fmt.decimals as number) : null;
|
| 419 |
const grouped = fmt?.thousands !== false;
|
| 420 |
const dec = (n: number) => (n > 0 ? "." + "0".repeat(n) : "");
|
| 421 |
+
// S76-T29: the same symbol `numberText` paints, `$` only for a currency field naming none.
|
| 422 |
+
const symbol = fmt?.currencySymbol ?? (f.type === "currency" ? "$" : "");
|
| 423 |
+
const money = f.type === "currency" || Boolean(symbol);
|
| 424 |
+
// Match numberText: no chosen decimals shows the full value (money at least 2 places, no trailing dot).
|
| 425 |
const numeric = d != null ? `${grouped ? "#,##0" : "0"}${dec(d)}`
|
| 426 |
+
: money ? `${grouped ? "#,##0" : "0"}.00##########` : "General";
|
| 427 |
// The stored magnitude already uses percent units. Quote the suffix so Excel cannot
|
| 428 |
// multiply it by 100; Field decimals and grouping still apply to the numeric portion.
|
| 429 |
if (f.type === "pct") return `${numeric}"%"`;
|
|
|
|
|
|
|
| 430 |
if (symbol) return `"${symbol}${symbol === "$" ? "" : " "}"${numeric}`;
|
| 431 |
return numeric === "General" ? null : numeric;
|
| 432 |
}
|
web/src/customer-grid/types.ts
CHANGED
|
@@ -539,7 +539,7 @@ export interface FieldFormat {
|
|
| 539 |
allowNegative?: boolean;
|
| 540 |
/** number/currency: thousands separators (absent = true, today's rendering). */
|
| 541 |
thousands?: boolean;
|
| 542 |
-
/** number/currency:
|
| 543 |
decimals?: number;
|
| 544 |
/** number/currency: abbreviate large values β 34.0M / 1.2k (one decimal). */
|
| 545 |
abbrev?: boolean;
|
|
|
|
| 539 |
allowNegative?: boolean;
|
| 540 |
/** number/currency: thousands separators (absent = true, today's rendering). */
|
| 541 |
thousands?: boolean;
|
| 542 |
+
/** number/currency: display-only decimal places, 0..4 (absent = the full value, never rounded). */
|
| 543 |
decimals?: number;
|
| 544 |
/** number/currency: abbreviate large values β 34.0M / 1.2k (one decimal). */
|
| 545 |
abbrev?: boolean;
|