Reviste el Catálogo: hub de mosaicos y matriz de productos
Tramo 3a. Odoo no tiene ni pantalla de mosaicos ni vista de matriz, así que las dos son acciones cliente; se montan en el Layout del core para que la miga, el eje y el revestimiento de las fases anteriores les lleguen igual que a una vista de Odoo (ADR-013 §9). El hub no reimplementa la navegación: cada mosaico abre el menú hijo que ya existe, y un mosaico cuyo menú no está visible para esa persona no se dibuja. Productos pasa a ser artículo × sucursal con precio efectivo y existencia; el clic en el renglón abre la ficha y los precios se siguen capturando donde siempre. Primero el test del método nuevo, que es público por RPC: a un gerente de sucursal no le viaja la columna de la plaza ajena, y se afirma con existencias distintas y distintas de cero en las dos, para que confundir una columna con otra tenga consecuencia visible. La existencia sale de una sola consulta agrupada por el branch_id del quant que puso ADR-017: agrupar por el mismo campo que usa la ir.rule hace que la cifra de la pantalla sea exactamente la que el servidor deja leer. El barrido de anchuras recorre ahora también el hub y la matriz. Como Productos cuelga del hub y no es pestaña de primer nivel, las secciones pueden llevar un paso extra: se entra por donde se entra de verdad. Detalle en ADR-012 y ADR-013 §9. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
53e9e65969
commit
a1be595ebd
15 files changed
+1047
-11
No files matched your search
@@ -0,0 +1,238 @@
|
||||
// Catálogo: el hub de mosaicos y la matriz de productos. Las dos son
|
||||
// acciones cliente, así que no heredan el panel de control revestido y
|
||||
// dibujan su propio encabezado contra el MISMO eje que el resto del panel
|
||||
// (ADR-013): si eligieran su propio margen se notaría al cambiar de pestaña.
|
||||
|
||||
// La clase del Layout cae sobre el propio .o_content, que ya se encarga del
|
||||
// alto y del desplazamiento: aquí solo va el fondo del panel y el aire de
|
||||
// abajo, que si no la última fila queda pegada al borde.
|
||||
.o_beyond_catalogo_hub,
|
||||
.o_beyond_catalogo_matriz {
|
||||
background: $beyond-surface;
|
||||
padding-bottom: 32px;
|
||||
}
|
||||
|
||||
.beyond_hub_eje,
|
||||
.beyond_cat_eje {
|
||||
@include beyond-ancho-contenido;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
// ── Hub ─────────────────────────────────────────────────────────────────
|
||||
// El título no se dibuja aquí: lo pone la miga del panel de control, igual
|
||||
// que en Clientes y Sucursales. Repetirlo daría dos títulos.
|
||||
.beyond_hub_mosaicos {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.beyond_hub_mosaico {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
padding: 24px;
|
||||
min-height: 180px;
|
||||
text-align: left;
|
||||
background: $beyond-panel-tarjeta;
|
||||
border: 1px solid $beyond-line;
|
||||
border-radius: $beyond-panel-radio-tarjeta;
|
||||
transition: transform .12s ease, box-shadow .12s ease;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 20px rgba(35, 32, 29, .10);
|
||||
}
|
||||
&:focus-visible {
|
||||
outline: 2px solid $beyond-panel-acento;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.beyond_hub_icono {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: $beyond-panel-tactil;
|
||||
height: $beyond-panel-tactil;
|
||||
margin-bottom: 8px;
|
||||
border-radius: $beyond-panel-radio-control;
|
||||
background: $beyond-panel-durazno;
|
||||
color: $beyond-panel-acento-pressed;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.beyond_hub_nombre {
|
||||
font-size: 19px;
|
||||
font-weight: 800;
|
||||
color: $beyond-ink;
|
||||
}
|
||||
|
||||
.beyond_hub_detalle {
|
||||
font-size: 14px;
|
||||
color: $beyond-ink-softer;
|
||||
}
|
||||
|
||||
// ── Matriz de productos ─────────────────────────────────────────────────
|
||||
.beyond_cat_nuevo {
|
||||
padding: 10px 22px;
|
||||
border-radius: 999px;
|
||||
background: $beyond-panel-acento;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
|
||||
&:hover { background: $beyond-panel-acento-hover; color: #fff; }
|
||||
}
|
||||
|
||||
.beyond_cat_controles {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.beyond_cat_buscador {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1 1 260px;
|
||||
max-width: 360px;
|
||||
padding: 0 14px;
|
||||
height: 44px;
|
||||
background: $beyond-panel-tarjeta;
|
||||
border: 1px solid $beyond-line;
|
||||
border-radius: 999px;
|
||||
color: $beyond-ink-softer;
|
||||
|
||||
&:focus-within { border-color: $beyond-panel-acento; }
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: $beyond-ink;
|
||||
|
||||
&:focus { outline: none; }
|
||||
}
|
||||
}
|
||||
|
||||
.beyond_cat_paginador {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-left: auto;
|
||||
color: $beyond-ink-soft;
|
||||
|
||||
.btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
color: $beyond-ink-soft;
|
||||
|
||||
&:disabled { color: $beyond-ink-muted; }
|
||||
}
|
||||
}
|
||||
|
||||
.beyond_cat_rango {
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.beyond_cat_tarjeta {
|
||||
background: $beyond-panel-tarjeta;
|
||||
border-radius: $beyond-panel-radio-ficha;
|
||||
padding: 8px 8px 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.beyond_cat_vacio {
|
||||
margin: 0;
|
||||
padding: 28px;
|
||||
color: $beyond-ink-softer;
|
||||
}
|
||||
|
||||
.beyond_cat_scroll { overflow-x: auto; }
|
||||
|
||||
.beyond_cat_tabla {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
|
||||
th, td {
|
||||
padding: 12px 14px;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
border-bottom: 1px solid $beyond-line;
|
||||
}
|
||||
|
||||
th {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: .04em;
|
||||
text-transform: uppercase;
|
||||
color: $beyond-ink-softer;
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover td { background: $beyond-surface-hover; }
|
||||
&:last-child td { border-bottom: 0; }
|
||||
}
|
||||
|
||||
// La columna del artículo se queda fija: con varias plazas se pierde de
|
||||
// vista de qué renglón se está leyendo el precio.
|
||||
.beyond_cat_fija {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
text-align: left;
|
||||
font-weight: 700;
|
||||
color: $beyond-ink;
|
||||
background: $beyond-panel-tarjeta;
|
||||
}
|
||||
|
||||
thead .beyond_cat_fija { z-index: 2; }
|
||||
|
||||
tbody tr:hover .beyond_cat_fija { background: $beyond-surface-hover; }
|
||||
|
||||
.beyond_cat_base { color: $beyond-ink-softer; }
|
||||
}
|
||||
|
||||
.beyond_cat_celda {
|
||||
.beyond_cat_precio {
|
||||
display: block;
|
||||
color: $beyond-ink;
|
||||
}
|
||||
|
||||
// Heredado del precio base: se ve distinto para no confundirlo con un
|
||||
// precio capturado a propósito (ADR-012).
|
||||
.beyond_heredado {
|
||||
color: $beyond-ink-muted;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
.beyond_cat_pildora {
|
||||
display: inline-block;
|
||||
margin-top: 4px;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
|
||||
&.beyond_hay {
|
||||
background: $beyond-panel-verde-suave;
|
||||
color: $beyond-panel-verde;
|
||||
}
|
||||
|
||||
// Cero o negativo. El negativo no es avería: dice que se vendió algo que
|
||||
// nunca se registró como recibido (ADR-012 §4).
|
||||
&.beyond_falta {
|
||||
background: $beyond-panel-rojo-suave;
|
||||
color: $beyond-panel-rojo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
import { Layout } from "@web/search/layout";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
|
||||
/**
|
||||
* Catálogo: los tres caminos, en mosaicos.
|
||||
*
|
||||
* Odoo no tiene pantalla de mosaicos, así que esto es una acción cliente.
|
||||
* Lo que NO hace es reimplementar la navegación: cada mosaico abre el menú
|
||||
* hijo que ya existe, con el servicio de menús, para que la pestaña activa,
|
||||
* la miga y la URL directa sigan funcionando igual que si se hubiera hecho
|
||||
* clic en la pestaña.
|
||||
*
|
||||
* Un mosaico cuyo menú no está visible para esta persona no se dibuja: los
|
||||
* permisos ya decidieron y no hay que decidirlos otra vez aquí.
|
||||
*/
|
||||
const MOSAICOS = [
|
||||
{
|
||||
xmlid: "beyond_branch.menu_beyond_catalogo_productos",
|
||||
titulo: _t("Productos"),
|
||||
detalle: _t("Qué se vende y a cuánto en cada sucursal, con su existencia."),
|
||||
icono: "fa-cube",
|
||||
},
|
||||
{
|
||||
xmlid: "beyond_branch.menu_beyond_catalogo_servicios",
|
||||
titulo: _t("Servicios"),
|
||||
detalle: _t("Cortes, tintes y todo lo que no lleva inventario."),
|
||||
icono: "fa-scissors",
|
||||
},
|
||||
{
|
||||
xmlid: "beyond_branch.menu_beyond_matriz_precios",
|
||||
titulo: _t("Precios por sucursal"),
|
||||
detalle: _t("Comparar plazas y capturar el precio de cada una."),
|
||||
icono: "fa-tags",
|
||||
},
|
||||
];
|
||||
|
||||
export class BeyondCatalogoHub extends Component {
|
||||
static template = "beyond_branch.CatalogoHub";
|
||||
// Se monta dentro del Layout del core para tener panel de control y
|
||||
// .o_content: así el revestimiento del panel (ADR-013) aplica igual que
|
||||
// en una vista de Odoo y la miga sigue siendo la del cliente web.
|
||||
static components = { Layout };
|
||||
static props = ["*"];
|
||||
|
||||
setup() {
|
||||
this.menu = useService("menu");
|
||||
this.mosaicos = MOSAICOS.filter((m) => this.menuDe(m.xmlid));
|
||||
}
|
||||
|
||||
menuDe(xmlid) {
|
||||
return this.menu.getAll().find((m) => m.xmlid === xmlid);
|
||||
}
|
||||
|
||||
async abrir(xmlid) {
|
||||
const destino = this.menuDe(xmlid);
|
||||
if (destino) {
|
||||
await this.menu.selectMenu(destino);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("actions").add("beyond_catalogo_hub", BeyondCatalogoHub);
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="beyond_branch.CatalogoHub">
|
||||
<Layout className="'o_beyond_catalogo_hub'" display="{ controlPanel: {} }">
|
||||
<div class="beyond_hub_eje">
|
||||
<div class="beyond_hub_mosaicos">
|
||||
<t t-foreach="mosaicos" t-as="mosaico" t-key="mosaico.xmlid">
|
||||
<button type="button" class="beyond_hub_mosaico"
|
||||
t-on-click="() => this.abrir(mosaico.xmlid)">
|
||||
<span class="beyond_hub_icono">
|
||||
<i class="fa" t-att-class="mosaico.icono"/>
|
||||
</span>
|
||||
<span class="beyond_hub_nombre" t-esc="mosaico.titulo"/>
|
||||
<span class="beyond_hub_detalle" t-esc="mosaico.detalle"/>
|
||||
</button>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -0,0 +1,137 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component, onWillStart, useState } from "@odoo/owl";
|
||||
import { Layout } from "@web/search/layout";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
|
||||
const POR_PAGINA = 40;
|
||||
const ESPERA_BUSQUEDA = 250;
|
||||
|
||||
/**
|
||||
* Catálogo × sucursales: precio efectivo y existencia en cada plaza.
|
||||
*
|
||||
* Sigue el patrón de la matriz de precios —acción cliente, columna del
|
||||
* artículo fija, una sola llamada por página— con dos diferencias:
|
||||
*
|
||||
* - No se edita aquí. El clic en el renglón abre la ficha del artículo; los
|
||||
* precios se capturan en «Precios por sucursal», que es la pantalla que
|
||||
* trata de eso.
|
||||
* - Pagina de verdad. La matriz de precios corta en 200 y avisa; aquí el
|
||||
* catálogo puede ser largo y se recorre de 40 en 40.
|
||||
*
|
||||
* Las columnas son las que el servidor entrega, no las que el componente
|
||||
* decide: a un gerente de sucursal no le viaja la columna de la plaza ajena
|
||||
* (ADR-017), así que no hay nada que ocultar en el navegador.
|
||||
*/
|
||||
export class BeyondCatalogoMatriz extends Component {
|
||||
static template = "beyond_branch.CatalogoMatriz";
|
||||
static components = { Layout };
|
||||
static props = ["*"];
|
||||
|
||||
setup() {
|
||||
this.orm = useService("orm");
|
||||
this.action = useService("action");
|
||||
this.state = useState({
|
||||
busqueda: "",
|
||||
offset: 0,
|
||||
datos: null,
|
||||
cargando: true,
|
||||
});
|
||||
onWillStart(() => this.cargar());
|
||||
}
|
||||
|
||||
/** Productos por defecto; el mismo componente sirve para servicios. */
|
||||
get tipo() {
|
||||
return this.props.action?.context?.beyond_tipo || "consu";
|
||||
}
|
||||
|
||||
get esServicio() {
|
||||
return this.tipo === "service";
|
||||
}
|
||||
|
||||
get titulo() {
|
||||
return this.esServicio ? _t("Servicios") : _t("Productos");
|
||||
}
|
||||
|
||||
get rango() {
|
||||
const datos = this.state.datos;
|
||||
if (!datos || !datos.mostrados) {
|
||||
return "0";
|
||||
}
|
||||
return `${datos.offset + 1}-${datos.offset + datos.mostrados}`;
|
||||
}
|
||||
|
||||
get hayAnterior() {
|
||||
return this.state.offset > 0;
|
||||
}
|
||||
|
||||
get haySiguiente() {
|
||||
const datos = this.state.datos;
|
||||
return !!datos && datos.offset + datos.mostrados < datos.total;
|
||||
}
|
||||
|
||||
async cargar() {
|
||||
this.state.cargando = true;
|
||||
try {
|
||||
this.state.datos = await this.orm.call(
|
||||
"product.template", "beyond_catalogo_datos",
|
||||
[this.tipo, this.state.busqueda, this.state.offset, POR_PAGINA]);
|
||||
} finally {
|
||||
this.state.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
onBuscar(ev) {
|
||||
clearTimeout(this._buscando);
|
||||
this.state.busqueda = ev.target.value;
|
||||
// Vuelve a la primera página: buscar y quedarse en la página 4 de un
|
||||
// resultado de dos páginas deja la pantalla en blanco sin explicación.
|
||||
this.state.offset = 0;
|
||||
this._buscando = setTimeout(() => this.cargar(), ESPERA_BUSQUEDA);
|
||||
}
|
||||
|
||||
async pasar(salto) {
|
||||
this.state.offset = Math.max(0, this.state.offset + salto * POR_PAGINA);
|
||||
await this.cargar();
|
||||
}
|
||||
|
||||
formato(valor, simbolo) {
|
||||
return `${simbolo}${valor.toLocaleString("es-MX", {
|
||||
minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
}
|
||||
|
||||
/** Cantidad sin decimales cuando es entera: «7», no «7.00». */
|
||||
cantidad(valor) {
|
||||
return valor.toLocaleString("es-MX", { maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Verde si hay, rojo si no. La existencia negativa es SEÑAL y no error
|
||||
* (ADR-012 §4): dice que se vendió algo que nunca se registró recibido,
|
||||
* así que se pinta como falta, no como avería.
|
||||
*/
|
||||
claseExistencia(existencia) {
|
||||
return existencia > 0 ? "beyond_hay" : "beyond_falta";
|
||||
}
|
||||
|
||||
async abrirFicha(articulo) {
|
||||
const accion = this.esServicio
|
||||
? "beyond_branch.action_beyond_catalogo_servicios"
|
||||
: "beyond_branch.action_beyond_catalogo_productos";
|
||||
await this.action.doAction(accion, {
|
||||
props: { resId: articulo.id },
|
||||
viewType: "form",
|
||||
});
|
||||
}
|
||||
|
||||
async nuevo() {
|
||||
const accion = this.esServicio
|
||||
? "beyond_branch.action_beyond_catalogo_servicios"
|
||||
: "beyond_branch.action_beyond_catalogo_productos";
|
||||
await this.action.doAction(accion, { viewType: "form" });
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("actions").add("beyond_catalogo_matriz", BeyondCatalogoMatriz);
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="beyond_branch.CatalogoMatriz">
|
||||
<Layout className="'o_beyond_catalogo_matriz'" display="{ controlPanel: {} }">
|
||||
<!-- «Nuevo» va en la ranura del panel de control, que es donde el
|
||||
resto del panel lo pone: después del título, nunca antes. -->
|
||||
<t t-set-slot="layout-buttons">
|
||||
<button type="button" class="btn beyond_cat_nuevo" t-on-click="nuevo">
|
||||
Nuevo
|
||||
</button>
|
||||
</t>
|
||||
<div class="beyond_cat_eje">
|
||||
<div class="beyond_cat_controles">
|
||||
<div class="beyond_cat_buscador">
|
||||
<i class="fa fa-search"/>
|
||||
<input type="search" placeholder="Buscar por nombre…"
|
||||
t-on-input="onBuscar"/>
|
||||
</div>
|
||||
<div class="beyond_cat_paginador" t-if="state.datos">
|
||||
<span class="beyond_cat_rango">
|
||||
<t t-esc="rango"/> de <t t-esc="state.datos.total"/>
|
||||
</span>
|
||||
<button type="button" class="btn" t-att-disabled="!hayAnterior"
|
||||
aria-label="Página anterior" t-on-click="() => this.pasar(-1)">
|
||||
<i class="fa fa-chevron-left"/>
|
||||
</button>
|
||||
<button type="button" class="btn" t-att-disabled="!haySiguiente"
|
||||
aria-label="Página siguiente" t-on-click="() => this.pasar(1)">
|
||||
<i class="fa fa-chevron-right"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="beyond_cat_tarjeta">
|
||||
<t t-if="state.cargando and !state.datos">
|
||||
<p class="beyond_cat_vacio">Cargando…</p>
|
||||
</t>
|
||||
<t t-elif="!state.datos.sucursales.length">
|
||||
<p class="beyond_cat_vacio">
|
||||
No tienes ninguna sucursal asignada, así que no hay
|
||||
columnas que mostrar.
|
||||
</p>
|
||||
</t>
|
||||
<t t-elif="!state.datos.articulos.length">
|
||||
<p class="beyond_cat_vacio">Sin artículos que mostrar.</p>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<div class="beyond_cat_scroll">
|
||||
<table class="beyond_cat_tabla">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="beyond_cat_fija">Artículo</th>
|
||||
<th class="beyond_cat_base">Base de red</th>
|
||||
<t t-foreach="state.datos.sucursales" t-as="sucursal"
|
||||
t-key="sucursal.id">
|
||||
<th t-esc="sucursal.nombre"/>
|
||||
</t>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="state.datos.articulos" t-as="articulo"
|
||||
t-key="articulo.id">
|
||||
<tr t-on-click="() => this.abrirFicha(articulo)">
|
||||
<td class="beyond_cat_fija" t-esc="articulo.nombre"/>
|
||||
<td class="beyond_cat_base"
|
||||
t-esc="formato(articulo.base, state.datos.simbolo)"/>
|
||||
<t t-foreach="articulo.celdas" t-as="celda"
|
||||
t-key="celda.branch_id">
|
||||
<td class="beyond_cat_celda">
|
||||
<span class="beyond_cat_precio"
|
||||
t-att-class="{'beyond_heredado': !celda.propio}"
|
||||
t-esc="formato(celda.precio, state.datos.simbolo)"/>
|
||||
<span t-if="celda.existencia !== null"
|
||||
class="beyond_cat_pildora"
|
||||
t-att-class="claseExistencia(celda.existencia)"
|
||||
t-esc="cantidad(celda.existencia)"/>
|
||||
</td>
|
||||
</t>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in new issue
Block a user