Files
BEYOND/addons/beyond_customer/static/src/ficha_stats.js
T
Jorem JuárezandClaude Opus 5 af852f2b41 Pone las cinco cifras en la fila del encabezado y afina el resto
Las tarjetas estaban donde debían y aun así no se veían: el bloque del
paginador ocupa todo el ancho restante y se pintaba encima. Estar en el sitio
correcto no es estar a la vista, y medir rectángulos no lo distingue; ahora la
prueba pregunta con elementFromPoint qué hay realmente en ese punto de la
pantalla, que es lo único que lo detecta.

La solución es dejar de flotarlas y meterlas EN esa fila. Un arch solo puede
poner cosas dentro del <sheet> y el panel de control es un hermano del
renderizador, así que las coloca un widget con un portal, como primer elemento
del bloque de navegación y con order -1 para quedar antes del paginador. Los
valores los pinta el componente Field nativo: formatear dinero, una fecha y un
many2one es trabajo del cliente web y no hay que rehacerlo.

La casa de la barra crece y va en tinta, como en el lanzador. Aquí el defecto
tampoco estaba donde parecía: la regla de tamaño existía y aun con !important
no aplicaba, porque el botón hereda el relleno de las entradas del navbar, su
caja de contenido quedaba en 15px y el SVG, como elemento flexible, se encogía
a ese hueco. Era flex-shrink, no especificidad.

En el listado, el título va antes que «Nuevo»: los dos cuelgan del mismo
contenedor, así que el orden se decide entre hermanos.

El buscador deja de leerse como dos barras encimadas: el campo pierde su caja
y su anillo de foco, y el foco se marca sobre la píldora entera. Va en la capa
del panel, así que vale para todos los buscadores de todas las secciones.

La tarjeta de la ficha se centra con márgenes iguales, y del encabezado sale
el rótulo «CLIENTES», que repetía lo que ya dice la píldora y obligaba a
apilar el bloque: ahora el nombre comparte eje con «← Clientes».

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-26 10:35:54 -06:00

61 lines
2.6 KiB
JavaScript

/** Part of Beyond. Collina Systems proprietary module. */
import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Field } from "@web/views/fields/field";
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
/**
* The five figures of the customer header.
*
* WHY A WIDGET WITH A PORTAL, and not markup in the arch. The design puts
* these cards in the header band, between the record name and the pager. A
* form arch can only place things inside the <sheet>, and the control panel is
* a SIBLING of the renderer: no stylesheet moves a node from one subtree to
* another. The first attempt positioned them absolutely over the band and the
* measurements were right — the browser reported them exactly where the design
* wants them — but nothing was visible, because
* `.o_control_panel_navigation` (the block that holds the pager) spans the
* remaining width and was painted on top. A portal puts the cards IN that row,
* as the first child, so they sit to the left of the pager and no one covers
* anyone.
*
* The values are rendered with the native Field component: formatting money, a
* date and a many2one is the web client's job and not something to redo here.
*/
export class BeyondFichaStats extends Component {
static template = "beyond_customer.FichaStats";
static components = { Field };
static props = { ...standardWidgetProps };
abrirHistorial() {
// El mismo botón estadístico de siempre, con su acción de servidor.
return this.props.record.model.action.doActionButton({
type: "object",
name: "action_view_beyond_orders",
resModel: this.props.record.resModel,
resId: this.props.record.resId,
resIds: [this.props.record.resId],
context: this.props.record.context,
});
}
/** Sin registro guardado no hay historial que abrir. */
get guardado() {
return !!this.props.record.resId;
}
}
registry.category("view_widgets").add("beyond_ficha_stats", {
component: BeyondFichaStats,
// Se declaran aquí para que las vistas no tengan que acordarse de
// cargarlos: el widget es quien los necesita.
fieldDependencies: [
{ name: "beyond_visit_count", type: "integer" },
{ name: "beyond_total_spent", type: "monetary" },
{ name: "beyond_last_visit", type: "datetime" },
{ name: "beyond_usual_branch_id", type: "many2one", relation: "beyond.branch" },
{ name: "beyond_avg_ticket", type: "monetary" },
{ name: "currency_id", type: "many2one", relation: "res.currency" },
],
});