Gastos estrena pantalla propia: mirar primero, capturar después
La vista nativa se notaba: filtros escondidos en un desplegable y una disposición de ERP. La pantalla nueva abre en lo que se hace a diario —cuánto se gastó— y deja la captura, que es ocasional, en un panel corto. - Filtros a la vista (patrón del Histórico): atajos hoy / este mes / este año, calendario, sucursal (el gerente no elige: es la suya), categoría y buscador. Categoría y búsqueda recortan la LISTA, no las cifras: el total del periodo es el total del periodo, y filtrar por «renta» no puede hacer que el negocio parezca gastar menos. - Tres cifras del cruce (total / operación / mercancía), del MISMO método que la tarjeta del tablero: una sola fuente. - Dona por categoría con la mercancía como rebanada propia: la dona y la cifra grande dicen el mismo número, y la red lo vigila (dona ≡ cifras). Etiquetas fijas con guía, como la del Histórico: en tablet no hay cursor que pasar por encima. - Lista agrupada por mes con su suma, orden por columna (reordena DENTRO del mes; el calendario no se desordena), clip de adjunto y marquita de recurrente por renglón, 60 por página. - Panel corto de captura: seis campos, «Guardar y otro» para tres gastos seguidos, adjuntos ahí mismo (la factura pide que el gasto exista: primero se guarda, después se anexa), papelera, y la puerta «Abrir ficha» al formulario nativo — el rastro de quién cambió qué vive en su chatter y la auditoría, rara pero real, entra por ahí. - Recurrentes como cajón: plantillas sin fecha no caen en una lista por mes. Alta y pausa ahí mismo; los generados salen en la lista con su marquita. Los dos menús hijos se funden: la pestaña abre la pantalla. - Descargas Excel/PDF con el motor de siempre: el servidor vuelve a resolver el filtro y el archivo trae el periodo COMPLETO, no la página. De las vistas nativas se repone búsqueda, edición (el mismo panel) y borrado; la exportación nativa NO se repone —la sustituye la descarga con filtros de servidor— y el reagrupado libre tampoco: la dona responde la proporción y los filtros el resto (veredictos acordados el 5-sep). Pruebas: seis de servidor y una de navegador (filtros a la vista, tres cifras, dona con rebanadas, grupo del mes —con desplazamiento explícito y su porqué—, panel corto con Guardar apagado en vacío). Rojos: la mercancía fuera de la dona y el disabled quitado cayeron con su prueba; el candado de plaza ajena NO cayó al sabotearlo porque la ir.rule de beyond.branch es segunda capa — la conducta que el test vigila sobrevive incluso sin la verificación explícita, que queda como mensaje claro sobre el tirante. La dona es la tercera del proyecto. Medida contra la del Histórico: similitud textual del 74% en el cuerpo del getter — la GEOMETRÍA (arcos, codo, columna, anti-encimado de etiquetas) es copia línea a línea; lo que difiere son nombres y colores. Candidata real a pieza compartida, como pidió anotarse; no se hace ahora. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ddf6e6c7e
commit
67e5d8c857
10 files changed
+1430
-7
No files matched your search
@@ -21,6 +21,13 @@ más lo gastado en operación.
|
||||
'views/beyond_gasto_views.xml',
|
||||
'data/cron.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'beyond_expense/static/src/gastos/gastos.js',
|
||||
'beyond_expense/static/src/gastos/gastos.xml',
|
||||
'beyond_expense/static/src/gastos/gastos.scss',
|
||||
],
|
||||
},
|
||||
'demo': ['demo/demo_gastos.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
from . import beyond_gasto
|
||||
from . import beyond_gasto_pantalla
|
||||
@@ -0,0 +1,201 @@
|
||||
# Part of Beyond. Collina Systems proprietary module.
|
||||
"""La pantalla de Gastos: mirar cuánto se gastó, primero; capturar, después.
|
||||
|
||||
La consulta es diaria y la captura ocasional, así que el servidor entrega
|
||||
todo lo que la pantalla mira de un tirón —cifras, dona y lista— con los
|
||||
MISMOS filtros resueltos aquí: el archivo de descarga no puede decir algo
|
||||
distinto a la pantalla porque sale de esta misma función.
|
||||
"""
|
||||
from datetime import date
|
||||
|
||||
from odoo import _, api, models
|
||||
from odoo.exceptions import AccessError, UserError
|
||||
|
||||
from .beyond_gasto import CATEGORIAS
|
||||
|
||||
POR_PAGINA = 60
|
||||
|
||||
ETIQUETAS = dict(CATEGORIAS)
|
||||
|
||||
|
||||
class BeyondGastoPantalla(models.AbstractModel):
|
||||
_name = 'beyond.gastos.pantalla'
|
||||
_description = 'Pantalla de gastos'
|
||||
_inherit = ['beyond.descarga']
|
||||
|
||||
# ── Alcance ─────────────────────────────────────────────────────────
|
||||
|
||||
@api.model
|
||||
def _beyond_es_director(self):
|
||||
return self.env.user.has_group('beyond_base.beyond_group_admin_general')
|
||||
|
||||
@api.model
|
||||
def _beyond_sucursal(self, branch_id=None):
|
||||
"""El gerente trabaja en la suya; pedir una ajena es un error, no un
|
||||
vacío (mismo criterio que Inventario). El director puede no elegir:
|
||||
entonces es toda la red."""
|
||||
propias = self.env.user.branch_ids
|
||||
if branch_id:
|
||||
sucursal = self.env['beyond.branch'].browse(int(branch_id)).exists()
|
||||
if not sucursal:
|
||||
raise UserError(_('Esa sucursal no existe.'))
|
||||
if not self._beyond_es_director() and sucursal not in propias:
|
||||
raise AccessError(_('Solo puedes ver los gastos de tu sucursal.'))
|
||||
return sucursal
|
||||
if self._beyond_es_director():
|
||||
return self.env['beyond.branch'].browse() # toda la red
|
||||
if not propias:
|
||||
raise AccessError(_('Tu usuario no tiene sucursal asignada.'))
|
||||
return propias[0]
|
||||
|
||||
@api.model
|
||||
def _beyond_periodo(self, filtros):
|
||||
"""Atajos hoy / mes / año, y el calendario gana si trae las fechas."""
|
||||
hoy = date.today()
|
||||
desde, hasta = filtros.get('desde'), filtros.get('hasta')
|
||||
if desde and hasta:
|
||||
return str(desde), str(hasta), _('del %s al %s') % (desde, hasta)
|
||||
atajo = filtros.get('atajo') or 'mes'
|
||||
if atajo == 'hoy':
|
||||
return hoy.isoformat(), hoy.isoformat(), _('hoy')
|
||||
if atajo == 'ano':
|
||||
return date(hoy.year, 1, 1).isoformat(), hoy.isoformat(), str(hoy.year)
|
||||
return (date(hoy.year, hoy.month, 1).isoformat(), hoy.isoformat(),
|
||||
hoy.strftime('%Y-%m'))
|
||||
|
||||
# ── Los datos de la pantalla, de un tirón ───────────────────────────
|
||||
|
||||
@api.model
|
||||
def beyond_datos(self, filtros=None):
|
||||
filtros = dict(filtros or {})
|
||||
sucursal = self._beyond_sucursal(filtros.get('branch_id'))
|
||||
desde, hasta, etiqueta = self._beyond_periodo(filtros)
|
||||
|
||||
dominio = [('fecha', '>=', desde), ('fecha', '<=', hasta)]
|
||||
if sucursal:
|
||||
dominio.append(('branch_id', '=', sucursal.id))
|
||||
if filtros.get('categoria'):
|
||||
dominio.append(('categoria', '=', filtros['categoria']))
|
||||
if filtros.get('busqueda'):
|
||||
dominio.append(('name', 'ilike', filtros['busqueda']))
|
||||
|
||||
Gasto = self.env['beyond.gasto']
|
||||
# Las cifras del cruce salen del MISMO método que la tarjeta del
|
||||
# tablero: una sola fuente, que es lo que la red vigila. La búsqueda
|
||||
# y la categoría no las recortan a propósito: son filtros de la
|
||||
# LISTA; el total del periodo es el total del periodo.
|
||||
cifras = Gasto.beyond_resumen(sucursal.id if sucursal else False,
|
||||
desde, hasta)
|
||||
|
||||
# La dona reparte el TOTAL: las categorías de operación más la
|
||||
# mercancía como rebanada propia — así la dona y la cifra grande
|
||||
# dicen el mismo número y nadie tiene que reconciliarlos de cabeza.
|
||||
dominio_dona = [d for d in dominio
|
||||
if d[0] not in ('categoria', 'name')]
|
||||
grupos = Gasto._read_group(dominio_dona, groupby=['categoria'],
|
||||
aggregates=['monto:sum'])
|
||||
dona = [{'clave': cat, 'etiqueta': ETIQUETAS.get(cat, cat),
|
||||
'valor': monto}
|
||||
for cat, monto in grupos if monto]
|
||||
if cifras['inventario']:
|
||||
dona.append({'clave': 'mercancia', 'etiqueta': _('Mercancía'),
|
||||
'valor': cifras['inventario']})
|
||||
|
||||
offset = int(filtros.get('offset') or 0)
|
||||
gastos = Gasto.search(dominio, order='fecha desc, id desc',
|
||||
offset=offset, limit=POR_PAGINA)
|
||||
adjuntos = {
|
||||
res_id: total for res_id, total in
|
||||
self.env['ir.attachment']._read_group(
|
||||
[('res_model', '=', 'beyond.gasto'),
|
||||
('res_id', 'in', gastos.ids)],
|
||||
groupby=['res_id'], aggregates=['__count'])}
|
||||
|
||||
return {
|
||||
'periodo': {'desde': desde, 'hasta': hasta, 'etiqueta': etiqueta},
|
||||
'puede_elegir': self._beyond_es_director(),
|
||||
'sucursal': ({'id': sucursal.id, 'nombre': sucursal.name}
|
||||
if sucursal else None),
|
||||
'sucursales': [{'id': b.id, 'nombre': b.name}
|
||||
for b in (self.env['beyond.branch'].search([])
|
||||
if self._beyond_es_director()
|
||||
else self.env.user.branch_ids)],
|
||||
'categorias': [{'clave': c, 'etiqueta': e} for c, e in CATEGORIAS],
|
||||
'cifras': cifras,
|
||||
'dona': dona,
|
||||
'filas': [{
|
||||
'id': g.id, 'fecha': g.fecha.isoformat(), 'mes': g.mes,
|
||||
'concepto': g.name, 'categoria': g.categoria,
|
||||
'categoria_etiqueta': ETIQUETAS.get(g.categoria, g.categoria),
|
||||
'sucursal': g.branch_id.name, 'branch_id': g.branch_id.id,
|
||||
'monto': g.monto,
|
||||
'recurrente': bool(g.recurrente_id),
|
||||
'adjuntos': adjuntos.get(g.id, 0),
|
||||
} for g in gastos],
|
||||
'total': Gasto.search_count(dominio),
|
||||
'offset': offset,
|
||||
'mostrados': len(gastos),
|
||||
}
|
||||
|
||||
# ── Descarga: los mismos filtros, resueltos otra vez aquí ───────────
|
||||
|
||||
@api.model
|
||||
def beyond_descargar(self, formato, filtros=None):
|
||||
if formato not in ('xlsx', 'pdf'):
|
||||
raise UserError(_('Formato de descarga no reconocido.'))
|
||||
filtros = dict(filtros or {}, offset=0)
|
||||
datos = self.beyond_datos(filtros)
|
||||
# El archivo trae el periodo COMPLETO, no la página que se veía:
|
||||
# una descarga recortada a 60 renglones diría menos que su cifra.
|
||||
Gasto = self.env['beyond.gasto']
|
||||
dominio = [('fecha', '>=', datos['periodo']['desde']),
|
||||
('fecha', '<=', datos['periodo']['hasta'])]
|
||||
if datos['sucursal']:
|
||||
dominio.append(('branch_id', '=', datos['sucursal']['id']))
|
||||
if filtros.get('categoria'):
|
||||
dominio.append(('categoria', '=', filtros['categoria']))
|
||||
if filtros.get('busqueda'):
|
||||
dominio.append(('name', 'ilike', filtros['busqueda']))
|
||||
gastos = Gasto.search(dominio, order='fecha desc, id desc')
|
||||
|
||||
cifras = datos['cifras']
|
||||
contexto = {
|
||||
'encabezado': {
|
||||
'titulo': _('Beyond · Gastos'),
|
||||
'datos': [
|
||||
(_('Periodo'), datos['periodo']['etiqueta']),
|
||||
(_('Sucursal'), datos['sucursal']['nombre']
|
||||
if datos['sucursal'] else _('Toda la red')),
|
||||
],
|
||||
'generado': self._beyond_generado(),
|
||||
'iva': self._beyond_aviso_iva(),
|
||||
},
|
||||
'cifras': [
|
||||
{'etiqueta': _('Total gastado'), 'texto': f"${cifras['total']:,.2f}",
|
||||
'valor': cifras['total'], 'formato': 'dinero'},
|
||||
{'etiqueta': _('Operación'), 'texto': f"${cifras['gastos']:,.2f}",
|
||||
'valor': cifras['gastos'], 'formato': 'dinero'},
|
||||
{'etiqueta': _('Mercancía'), 'texto': f"${cifras['inventario']:,.2f}",
|
||||
'valor': cifras['inventario'], 'formato': 'dinero'},
|
||||
],
|
||||
'bloques': [{
|
||||
'titulo': _('Gastos del periodo'),
|
||||
'columnas': [
|
||||
{'etiqueta': _('Fecha'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Concepto'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Categoría'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Sucursal'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Monto'), 'formato': 'dinero'},
|
||||
],
|
||||
'filas': [[g.fecha.isoformat(), g.name,
|
||||
ETIQUETAS.get(g.categoria, g.categoria),
|
||||
g.branch_id.name, g.monto] for g in gastos],
|
||||
'grafica': None,
|
||||
}],
|
||||
}
|
||||
return self._beyond_archivo(
|
||||
contexto, formato,
|
||||
self._beyond_nombre_archivo(
|
||||
['Beyond', 'Gastos',
|
||||
datos['sucursal']['nombre'] if datos['sucursal'] else 'Red',
|
||||
datos['periodo']['etiqueta']], formato))
|
||||
@@ -0,0 +1,413 @@
|
||||
/** @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 ESPERA_BUSQUEDA = 250;
|
||||
|
||||
// Un color por categoría, fijo por CLAVE y no por orden: filtrar no puede
|
||||
// recolorear la dona (la lección de ADR-020). La mercancía lleva el suyo.
|
||||
const COLORES = {
|
||||
renta: "#0F6B5C", servicios: "#2E9B8B", insumos: "#7FB8AC",
|
||||
mantenimiento: "#C97B3D", publicidad: "#8B6BB8", otro: "#9AA6A0",
|
||||
mercancia: "#4A453E",
|
||||
};
|
||||
|
||||
/**
|
||||
* Gastos: mirar cuánto se gastó, primero; capturar, después.
|
||||
*
|
||||
* La consulta es diaria y la captura ocasional, así que la pantalla abre en
|
||||
* las cifras y la lista, y el alta es un panel corto — seis campos y
|
||||
* guardar, tres gastos seguidos sin sentirse pesado. Los filtros van a la
|
||||
* vista, como en el Histórico del punto de venta: un control que hay que
|
||||
* descubrir es un control que nadie usa.
|
||||
*/
|
||||
export class BeyondGastos extends Component {
|
||||
static template = "beyond_expense.Gastos";
|
||||
static components = { Layout };
|
||||
static props = ["*"];
|
||||
|
||||
setup() {
|
||||
this.orm = useService("orm");
|
||||
this.action = useService("action");
|
||||
this.notification = useService("notification");
|
||||
this.state = useState({
|
||||
filtros: { atajo: "mes", desde: "", hasta: "", branch_id: false,
|
||||
categoria: "", busqueda: "", offset: 0 },
|
||||
datos: null,
|
||||
cargando: true,
|
||||
orden: { campo: "fecha", dir: -1 },
|
||||
panel: null, // el gasto en captura/edición
|
||||
adjuntos: [], // los archivos del gasto del panel
|
||||
recurrentes: null, // null = cajón cerrado
|
||||
nuevoRecurrente: null,
|
||||
guardando: false,
|
||||
descargando: false,
|
||||
});
|
||||
onWillStart(() => this.cargar());
|
||||
}
|
||||
|
||||
async cargar() {
|
||||
this.state.cargando = true;
|
||||
try {
|
||||
this.state.datos = await this.orm.call(
|
||||
"beyond.gastos.pantalla", "beyond_datos",
|
||||
[{ ...this.state.filtros }]);
|
||||
} finally {
|
||||
this.state.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Filtros ─────────────────────────────────────────────────────────
|
||||
|
||||
async elegirAtajo(atajo) {
|
||||
Object.assign(this.state.filtros,
|
||||
{ atajo, desde: "", hasta: "", offset: 0 });
|
||||
await this.cargar();
|
||||
}
|
||||
|
||||
get hoyIso() {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
async cambiarFecha(campo, ev) {
|
||||
this.state.filtros[campo] = ev.target.value;
|
||||
this.state.filtros.offset = 0;
|
||||
if (this.state.filtros.desde && this.state.filtros.hasta) {
|
||||
this.state.filtros.atajo = "";
|
||||
await this.cargar();
|
||||
}
|
||||
}
|
||||
|
||||
async cambiarFiltro(campo, ev) {
|
||||
this.state.filtros[campo] = campo === "branch_id"
|
||||
? (parseInt(ev.target.value) || false)
|
||||
: ev.target.value;
|
||||
this.state.filtros.offset = 0;
|
||||
await this.cargar();
|
||||
}
|
||||
|
||||
onBuscar(ev) {
|
||||
clearTimeout(this._buscando);
|
||||
this.state.filtros.busqueda = ev.target.value;
|
||||
this.state.filtros.offset = 0;
|
||||
this._buscando = setTimeout(() => this.cargar(), ESPERA_BUSQUEDA);
|
||||
}
|
||||
|
||||
async paginar(salto) {
|
||||
this.state.filtros.offset = Math.max(
|
||||
0, this.state.filtros.offset + salto * 60);
|
||||
await this.cargar();
|
||||
}
|
||||
|
||||
// ── La lista, agrupada por mes con su suma ─────────────────────────
|
||||
|
||||
ordenarPor(campo) {
|
||||
const orden = this.state.orden;
|
||||
orden.dir = orden.campo === campo ? -orden.dir : 1;
|
||||
orden.campo = campo;
|
||||
}
|
||||
|
||||
get grupos() {
|
||||
const { campo, dir } = this.state.orden;
|
||||
const filas = [...(this.state.datos?.filas || [])].sort((a, b) => {
|
||||
const x = a[campo], y = b[campo];
|
||||
return (x > y ? 1 : x < y ? -1 : 0) * dir;
|
||||
});
|
||||
const meses = new Map();
|
||||
for (const fila of filas) {
|
||||
if (!meses.has(fila.mes)) {
|
||||
meses.set(fila.mes, { mes: fila.mes, suma: 0, filas: [] });
|
||||
}
|
||||
const grupo = meses.get(fila.mes);
|
||||
grupo.suma += fila.monto;
|
||||
grupo.filas.push(fila);
|
||||
}
|
||||
// Los meses en orden descendente siempre: el orden por columna
|
||||
// reordena DENTRO del mes, no el calendario.
|
||||
return [...meses.values()].sort((a, b) => b.mes.localeCompare(a.mes));
|
||||
}
|
||||
|
||||
// ── La dona: proporción del gasto, total al centro ──────────────────
|
||||
|
||||
color(clave) {
|
||||
return COLORES[clave] || COLORES.otro;
|
||||
}
|
||||
|
||||
get donaTotal() {
|
||||
const partes = this.state.datos?.dona || [];
|
||||
return this.dinero(partes.reduce((s, p) => s + p.valor, 0));
|
||||
}
|
||||
|
||||
/** Misma geometría que la dona del Histórico (etiquetas fijas con guía:
|
||||
* en tablet no hay cursor que pasar por encima). Tercera dona del
|
||||
* proyecto — anotado para evaluar una pieza compartida. */
|
||||
get dona() {
|
||||
const partes = (this.state.datos?.dona || []).filter((p) => p.valor > 0);
|
||||
const total = partes.reduce((s, p) => s + p.valor, 0);
|
||||
if (!total) {
|
||||
return [];
|
||||
}
|
||||
const cx = 500, cy = 150, radio = 120, grueso = 46;
|
||||
const CODO = 148, COLUMNA = 250;
|
||||
let angulo = -Math.PI / 2;
|
||||
const arcos = partes.map((p) => {
|
||||
const barrido = (p.valor / total) * Math.PI * 2;
|
||||
const fin = angulo + barrido;
|
||||
const medio = angulo + barrido / 2;
|
||||
const punto = (a, r) =>
|
||||
`${(cx + r * Math.cos(a)).toFixed(1)},${(cy + r * Math.sin(a)).toFixed(1)}`;
|
||||
const largo = barrido > Math.PI ? 1 : 0;
|
||||
const d = [
|
||||
`M ${punto(angulo, radio)}`,
|
||||
`A ${radio} ${radio} 0 ${largo} 1 ${punto(fin, radio)}`,
|
||||
`L ${punto(fin, radio - grueso)}`,
|
||||
`A ${radio - grueso} ${radio - grueso} 0 ${largo} 0 ${punto(angulo, radio - grueso)}`,
|
||||
"Z",
|
||||
].join(" ");
|
||||
angulo = fin;
|
||||
const derecha = Math.cos(medio) >= 0;
|
||||
const porcentaje = (p.valor / total) * 100;
|
||||
return {
|
||||
...p, d,
|
||||
color: this.color(p.clave),
|
||||
porcentaje,
|
||||
montoTexto: this.dinero(p.valor),
|
||||
anclaje: derecha ? "start" : "end",
|
||||
derecha,
|
||||
sx: cx + Math.cos(medio) * (radio + 4),
|
||||
sy: cy + Math.sin(medio) * (radio + 4),
|
||||
ex: cx + Math.cos(medio) * CODO,
|
||||
ey: cy + Math.sin(medio) * CODO,
|
||||
tx: cx + (derecha ? COLUMNA : -COLUMNA),
|
||||
};
|
||||
});
|
||||
for (const lado of [true, false]) {
|
||||
const suyas = arcos.filter((a) => a.derecha === lado)
|
||||
.sort((a, b) => a.ey - b.ey);
|
||||
let minimo = -Infinity;
|
||||
for (const arco of suyas) {
|
||||
arco.ty = Math.max(arco.ey, minimo);
|
||||
minimo = arco.ty + 30;
|
||||
}
|
||||
}
|
||||
return arcos;
|
||||
}
|
||||
|
||||
// ── El panel corto: capturar y corregir son el mismo gesto ──────────
|
||||
|
||||
async abrirPanel(fila) {
|
||||
this.state.panel = fila
|
||||
? { id: fila.id, name: fila.concepto, monto: String(fila.monto),
|
||||
fecha: fila.fecha, branch_id: fila.branch_id,
|
||||
categoria: fila.categoria }
|
||||
: { id: null, name: "", monto: "",
|
||||
fecha: this.hoyIso,
|
||||
branch_id: this.state.datos.sucursal?.id
|
||||
|| this.state.datos.sucursales[0]?.id,
|
||||
categoria: "otro" };
|
||||
this.state.adjuntos = fila ? await this.orm.searchRead(
|
||||
"ir.attachment",
|
||||
[["res_model", "=", "beyond.gasto"], ["res_id", "=", fila.id]],
|
||||
["name"]) : [];
|
||||
}
|
||||
|
||||
cerrarPanel() {
|
||||
this.state.panel = null;
|
||||
this.state.adjuntos = [];
|
||||
}
|
||||
|
||||
escribirPanel(campo, ev) {
|
||||
this.state.panel[campo] = campo === "branch_id"
|
||||
? parseInt(ev.target.value) : ev.target.value;
|
||||
}
|
||||
|
||||
get panelValido() {
|
||||
const p = this.state.panel;
|
||||
const monto = parseFloat(String(p?.monto).replace(",", "."));
|
||||
return p && p.name.trim() && monto > 0 && p.fecha && p.branch_id;
|
||||
}
|
||||
|
||||
async guardarPanel(seguir) {
|
||||
if (!this.panelValido || this.state.guardando) {
|
||||
return;
|
||||
}
|
||||
this.state.guardando = true;
|
||||
const p = this.state.panel;
|
||||
const valores = {
|
||||
name: p.name.trim(),
|
||||
monto: parseFloat(String(p.monto).replace(",", ".")),
|
||||
fecha: p.fecha, branch_id: p.branch_id, categoria: p.categoria,
|
||||
};
|
||||
try {
|
||||
if (p.id) {
|
||||
await this.orm.write("beyond.gasto", [p.id], valores);
|
||||
} else {
|
||||
p.id = (await this.orm.create("beyond.gasto", [valores]))[0];
|
||||
}
|
||||
await this.cargar();
|
||||
if (seguir) {
|
||||
// Tres gastos seguidos sin sentirse pesado: el panel se
|
||||
// limpia y el foco sigue aquí.
|
||||
await this.abrirPanel(null);
|
||||
} else {
|
||||
this.cerrarPanel();
|
||||
}
|
||||
} finally {
|
||||
this.state.guardando = false;
|
||||
}
|
||||
}
|
||||
|
||||
async borrarPanel() {
|
||||
if (!this.state.panel?.id) {
|
||||
return;
|
||||
}
|
||||
await this.orm.unlink("beyond.gasto", [this.state.panel.id]);
|
||||
this.cerrarPanel();
|
||||
await this.cargar();
|
||||
}
|
||||
|
||||
/** La puerta a la ficha nativa: el rastro de quién cambió qué vive en
|
||||
* su chatter, y la auditoría —rara pero real— entra por aquí. */
|
||||
async abrirFicha() {
|
||||
const id = this.state.panel?.id;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
await this.action.doAction({
|
||||
type: "ir.actions.act_window", res_model: "beyond.gasto",
|
||||
res_id: id, views: [[false, "form"]], target: "current",
|
||||
});
|
||||
}
|
||||
|
||||
// ── Adjuntos: la factura, en el propio gasto ────────────────────────
|
||||
|
||||
async subirAdjunto(ev) {
|
||||
const archivo = ev.target.files?.[0];
|
||||
if (!archivo || !this.state.panel?.id) {
|
||||
return;
|
||||
}
|
||||
const datas = await new Promise((resolver) => {
|
||||
const lector = new FileReader();
|
||||
lector.onload = () => resolver(lector.result.split(",")[1]);
|
||||
lector.readAsDataURL(archivo);
|
||||
});
|
||||
const [id] = await this.orm.create("ir.attachment", [{
|
||||
name: archivo.name, datas,
|
||||
res_model: "beyond.gasto", res_id: this.state.panel.id,
|
||||
}]);
|
||||
this.state.adjuntos = [...this.state.adjuntos,
|
||||
{ id, name: archivo.name }];
|
||||
ev.target.value = "";
|
||||
await this.cargar(); // el clip del renglón
|
||||
}
|
||||
|
||||
enlaceAdjunto(adjunto) {
|
||||
return `/web/content/${adjunto.id}?download=true`;
|
||||
}
|
||||
|
||||
async quitarAdjunto(adjunto) {
|
||||
await this.orm.unlink("ir.attachment", [adjunto.id]);
|
||||
this.state.adjuntos = this.state.adjuntos.filter(
|
||||
(a) => a.id !== adjunto.id);
|
||||
await this.cargar();
|
||||
}
|
||||
|
||||
// ── Recurrentes: el cajón ───────────────────────────────────────────
|
||||
|
||||
async abrirRecurrentes() {
|
||||
if (this.state.recurrentes) {
|
||||
this.state.recurrentes = null;
|
||||
return;
|
||||
}
|
||||
this.state.recurrentes = await this.orm.searchRead(
|
||||
"beyond.gasto.recurrente", [],
|
||||
["name", "monto", "dia", "categoria", "branch_id", "activo"]);
|
||||
this.state.nuevoRecurrente = null;
|
||||
}
|
||||
|
||||
prepararRecurrente() {
|
||||
this.state.nuevoRecurrente = {
|
||||
name: "", monto: "", dia: 1, categoria: "renta",
|
||||
branch_id: this.state.datos.sucursal?.id
|
||||
|| this.state.datos.sucursales[0]?.id,
|
||||
};
|
||||
}
|
||||
|
||||
escribirRecurrente(campo, ev) {
|
||||
this.state.nuevoRecurrente[campo] =
|
||||
["branch_id", "dia"].includes(campo)
|
||||
? parseInt(ev.target.value) : ev.target.value;
|
||||
}
|
||||
|
||||
async guardarRecurrente() {
|
||||
const r = this.state.nuevoRecurrente;
|
||||
const monto = parseFloat(String(r?.monto).replace(",", "."));
|
||||
if (!r?.name.trim() || !(monto > 0)) {
|
||||
return;
|
||||
}
|
||||
await this.orm.create("beyond.gasto.recurrente", [{
|
||||
name: r.name.trim(), monto, dia: r.dia,
|
||||
categoria: r.categoria, branch_id: r.branch_id,
|
||||
}]);
|
||||
this.state.recurrentes = null;
|
||||
await this.abrirRecurrentes();
|
||||
}
|
||||
|
||||
async alternarRecurrente(recurrente) {
|
||||
await this.orm.write("beyond.gasto.recurrente", [recurrente.id],
|
||||
{ activo: !recurrente.activo });
|
||||
recurrente.activo = !recurrente.activo;
|
||||
}
|
||||
|
||||
// ── Descargas: el servidor vuelve a resolver el filtro ─────────────
|
||||
|
||||
async descargar(formato) {
|
||||
if (this.state.descargando) {
|
||||
return;
|
||||
}
|
||||
this.state.descargando = true;
|
||||
try {
|
||||
const archivo = await this.orm.call(
|
||||
"beyond.gastos.pantalla", "beyond_descargar",
|
||||
[formato, { ...this.state.filtros }]);
|
||||
const binario = atob(archivo.contenido);
|
||||
const bytes = new Uint8Array(binario.length);
|
||||
for (let i = 0; i < binario.length; i++) {
|
||||
bytes[i] = binario.charCodeAt(i);
|
||||
}
|
||||
const url = URL.createObjectURL(
|
||||
new Blob([bytes], { type: archivo.mime }));
|
||||
const enlace = document.createElement("a");
|
||||
enlace.href = url;
|
||||
enlace.download = archivo.nombre;
|
||||
document.body.appendChild(enlace);
|
||||
enlace.click();
|
||||
enlace.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
} finally {
|
||||
this.state.descargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Formato ─────────────────────────────────────────────────────────
|
||||
|
||||
dinero(valor) {
|
||||
return `$${(valor || 0).toLocaleString("es-MX",
|
||||
{ minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
}
|
||||
|
||||
etiquetaMes(mes) {
|
||||
const [ano, numero] = mes.split("-");
|
||||
const nombres = [_t("enero"), _t("febrero"), _t("marzo"), _t("abril"),
|
||||
_t("mayo"), _t("junio"), _t("julio"), _t("agosto"),
|
||||
_t("septiembre"), _t("octubre"), _t("noviembre"),
|
||||
_t("diciembre")];
|
||||
return `${nombres[parseInt(numero) - 1]} ${ano}`;
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("actions").add("beyond_gastos", BeyondGastos);
|
||||
@@ -0,0 +1,259 @@
|
||||
/* Part of Beyond. Collina Systems proprietary module.
|
||||
La pantalla de Gastos: misma familia visual que Inventario y el
|
||||
Histórico — tarjetas blancas, línea suave, verde de la casa. */
|
||||
|
||||
$gastos-linea: #F3F1EB;
|
||||
$gastos-tinta: #23201D;
|
||||
$gastos-tinta-suave: #6E6A63;
|
||||
$gastos-verde: #0F6B5C;
|
||||
$gastos-fondo: #FAF9F7;
|
||||
|
||||
.o_beyond_gastos {
|
||||
background: $gastos-fondo;
|
||||
|
||||
.beyond_gastos_eje {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 18px 20px 40px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.beyond_gastos_encabezado {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.beyond_gastos_titulo { font-size: 22px; font-weight: 800; color: $gastos-tinta; }
|
||||
.beyond_gastos_relleno { flex: 1; }
|
||||
|
||||
.beyond_gastos_nuevo {
|
||||
background: $gastos-verde;
|
||||
color: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 10px 16px;
|
||||
font-weight: 700;
|
||||
&:disabled { opacity: 0.5; }
|
||||
&:hover { color: #fff; filter: brightness(1.05); }
|
||||
}
|
||||
.beyond_gastos_secundario {
|
||||
border: 1px solid $gastos-linea;
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 10px 14px;
|
||||
&.beyond_activa { border-color: $gastos-verde; color: $gastos-verde; }
|
||||
}
|
||||
.beyond_gastos_peligro {
|
||||
border: 1px solid #E8D5D2;
|
||||
color: #9C0006;
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
// ── Filtros a la vista ───────────────────────────────────────────
|
||||
.beyond_gastos_filtros {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 18px;
|
||||
background: #fff;
|
||||
border: 1px solid $gastos-linea;
|
||||
border-radius: 14px;
|
||||
padding: 14px 16px;
|
||||
|
||||
.beyond_gastos_buscador { flex: 1; min-width: 180px; }
|
||||
}
|
||||
.beyond_gastos_etiqueta {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: $gastos-tinta-suave;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.beyond_gastos_pastillas { display: flex; gap: 6px; }
|
||||
.beyond_gastos_pastilla {
|
||||
border: 1px solid $gastos-linea;
|
||||
background: #fff;
|
||||
border-radius: 999px;
|
||||
padding: 8px 14px;
|
||||
&.beyond_activa {
|
||||
background: $gastos-verde;
|
||||
border-color: $gastos-verde;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
.beyond_gastos_fechas { display: flex; gap: 8px; }
|
||||
.beyond_gastos_campo {
|
||||
border: 1px solid $gastos-linea;
|
||||
border-radius: 10px;
|
||||
padding: 8px 10px;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
// ── Cifras ───────────────────────────────────────────────────────
|
||||
.beyond_gastos_cifras {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 14px;
|
||||
@media (max-width: 800px) { grid-template-columns: 1fr; }
|
||||
}
|
||||
.beyond_gastos_cifra {
|
||||
background: #fff;
|
||||
border: 1px solid $gastos-linea;
|
||||
border-radius: 14px;
|
||||
padding: 16px 18px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.beyond_gastos_cifra_titulo {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: $gastos-tinta-suave;
|
||||
}
|
||||
.beyond_gastos_cifra_valor { font-size: 26px; font-weight: 800; color: $gastos-tinta; }
|
||||
.beyond_gastos_cifra_pie { font-size: 12px; color: $gastos-tinta-suave; }
|
||||
|
||||
// ── Bloques (dona, lista, recurrentes) ───────────────────────────
|
||||
.beyond_gastos_bloque {
|
||||
background: #fff;
|
||||
border: 1px solid $gastos-linea;
|
||||
border-radius: 14px;
|
||||
padding: 16px 18px;
|
||||
position: relative;
|
||||
}
|
||||
.beyond_gastos_bloque_titulo { font-weight: 800; color: $gastos-tinta; }
|
||||
.beyond_gastos_bloque_sub { color: $gastos-tinta-suave; font-size: 13px; margin-left: 8px; }
|
||||
.beyond_gastos_bloque_encabezado {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
.beyond_gastos_secundario { margin-left: auto; }
|
||||
}
|
||||
|
||||
.beyond_gastos_dona {
|
||||
width: 100%;
|
||||
max-height: 320px;
|
||||
display: block;
|
||||
}
|
||||
.beyond_gastos_dona_nombre { font-size: 15px; font-weight: 700; fill: $gastos-tinta; }
|
||||
.beyond_gastos_dona_monto { font-size: 13px; fill: $gastos-tinta-suave; }
|
||||
.beyond_gastos_dona_total { font-size: 26px; font-weight: 800; fill: $gastos-tinta; }
|
||||
.beyond_gastos_dona_leyenda { font-size: 12px; fill: $gastos-tinta-suave; }
|
||||
|
||||
// ── La lista ─────────────────────────────────────────────────────
|
||||
.beyond_gastos_tabla {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: $gastos-tinta-suave;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid $gastos-linea;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
i { margin-left: 4px; }
|
||||
&.beyond_ordenada { color: $gastos-verde; }
|
||||
}
|
||||
td { padding: 10px; border-bottom: 1px solid $gastos-linea; }
|
||||
.beyond_num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
}
|
||||
.beyond_gastos_grupo td {
|
||||
background: $gastos-fondo;
|
||||
font-weight: 800;
|
||||
color: $gastos-tinta;
|
||||
}
|
||||
.beyond_gastos_fila { cursor: pointer; }
|
||||
.beyond_gastos_fila:hover td { background: #FBFAF8; }
|
||||
.beyond_gastos_marca { margin-left: 6px; color: $gastos-tinta-suave; font-size: 12px; }
|
||||
.beyond_gastos_clip { width: 34px; text-align: center; color: $gastos-tinta-suave; }
|
||||
|
||||
.beyond_gastos_paginador {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 10px;
|
||||
color: $gastos-tinta-suave;
|
||||
.btn { border: 1px solid $gastos-linea; }
|
||||
}
|
||||
|
||||
// ── Recurrentes ──────────────────────────────────────────────────
|
||||
.beyond_gastos_recurrente,
|
||||
.beyond_gastos_recurrente_alta {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 0.8fr 1fr auto;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 9px 4px;
|
||||
border-top: 1px solid $gastos-linea;
|
||||
}
|
||||
.beyond_gastos_recurrente_alta { grid-template-columns: 2fr 1fr 0.9fr 1.2fr 1.2fr auto; }
|
||||
.beyond_gastos_recurrente.beyond_apagado { opacity: 0.45; }
|
||||
|
||||
// ── El panel corto ───────────────────────────────────────────────
|
||||
.beyond_gastos_velo {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(35, 32, 29, 0.35);
|
||||
z-index: 90;
|
||||
}
|
||||
.beyond_gastos_panel {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: min(400px, 92vw);
|
||||
background: #fff;
|
||||
z-index: 91;
|
||||
padding: 18px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
overflow-y: auto;
|
||||
box-shadow: -12px 0 30px rgba(35, 32, 29, 0.12);
|
||||
}
|
||||
.beyond_gastos_panel_encabezado {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 17px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.beyond_gastos_panel_acciones {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
.beyond_gastos_adjunto {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
border: 1px solid $gastos-linea;
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.beyond_gastos_nota { color: $gastos-tinta-suave; font-size: 12px; }
|
||||
|
||||
.beyond_gastos_vacio {
|
||||
text-align: center;
|
||||
color: $gastos-tinta-suave;
|
||||
padding: 26px 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
i { font-size: 22px; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="beyond_expense.Gastos">
|
||||
<Layout display="{ controlPanel: {} }" className="'o_beyond_gastos o_content'">
|
||||
<div class="beyond_gastos_eje">
|
||||
|
||||
<!-- ══ Encabezado: mirar primero, capturar después ══ -->
|
||||
<div class="beyond_gastos_encabezado">
|
||||
<span class="beyond_gastos_titulo">Gastos</span>
|
||||
<span class="beyond_gastos_relleno"/>
|
||||
<button type="button" class="btn beyond_gastos_secundario"
|
||||
t-att-disabled="state.descargando"
|
||||
t-on-click="() => this.descargar('xlsx')">
|
||||
<i class="fa fa-file-excel-o"/> Excel
|
||||
</button>
|
||||
<button type="button" class="btn beyond_gastos_secundario"
|
||||
t-att-disabled="state.descargando"
|
||||
t-on-click="() => this.descargar('pdf')">
|
||||
<i class="fa fa-file-pdf-o"/> PDF
|
||||
</button>
|
||||
<button type="button" class="btn beyond_gastos_secundario"
|
||||
t-att-class="{ beyond_activa: state.recurrentes }"
|
||||
t-on-click="abrirRecurrentes">
|
||||
<i class="fa fa-refresh"/> Recurrentes
|
||||
</button>
|
||||
<button type="button" class="btn beyond_gastos_nuevo"
|
||||
t-on-click="() => this.abrirPanel(null)">
|
||||
<i class="fa fa-plus"/> Nuevo gasto
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ══ Filtros a la vista, no en un desplegable ══ -->
|
||||
<div class="beyond_gastos_filtros" t-if="state.datos">
|
||||
<div>
|
||||
<label class="beyond_gastos_etiqueta">Periodo</label>
|
||||
<div class="beyond_gastos_pastillas">
|
||||
<t t-foreach="[['hoy','Hoy'],['mes','Este mes'],['ano','Este año']]"
|
||||
t-as="atajo" t-key="atajo[0]">
|
||||
<button type="button" class="beyond_gastos_pastilla"
|
||||
t-att-class="state.filtros.atajo === atajo[0] ? 'beyond_activa' : ''"
|
||||
t-on-click="() => this.elegirAtajo(atajo[0])"
|
||||
t-esc="atajo[1]"/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="beyond_gastos_etiqueta">O del… al…</label>
|
||||
<div class="beyond_gastos_fechas">
|
||||
<input type="date" class="beyond_gastos_campo"
|
||||
t-att-value="state.filtros.desde"
|
||||
t-att-max="state.filtros.hasta or hoyIso"
|
||||
t-on-change="(ev) => this.cambiarFecha('desde', ev)"/>
|
||||
<input type="date" class="beyond_gastos_campo"
|
||||
t-att-value="state.filtros.hasta"
|
||||
t-att-min="state.filtros.desde"
|
||||
t-att-max="hoyIso"
|
||||
t-on-change="(ev) => this.cambiarFecha('hasta', ev)"/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- El gerente no elige plaza: es la suya. -->
|
||||
<div t-if="state.datos.puede_elegir">
|
||||
<label class="beyond_gastos_etiqueta">Sucursal</label>
|
||||
<select class="beyond_gastos_campo"
|
||||
t-on-change="(ev) => this.cambiarFiltro('branch_id', ev)">
|
||||
<option value="">Toda la red</option>
|
||||
<option t-foreach="state.datos.sucursales" t-as="sucursal"
|
||||
t-key="sucursal.id" t-att-value="sucursal.id"
|
||||
t-att-selected="state.filtros.branch_id === sucursal.id"
|
||||
t-esc="sucursal.nombre"/>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="beyond_gastos_etiqueta">Categoría</label>
|
||||
<select class="beyond_gastos_campo"
|
||||
t-on-change="(ev) => this.cambiarFiltro('categoria', ev)">
|
||||
<option value="">Todas</option>
|
||||
<option t-foreach="state.datos.categorias" t-as="categoria"
|
||||
t-key="categoria.clave" t-att-value="categoria.clave"
|
||||
t-att-selected="state.filtros.categoria === categoria.clave"
|
||||
t-esc="categoria.etiqueta"/>
|
||||
</select>
|
||||
</div>
|
||||
<div class="beyond_gastos_buscador">
|
||||
<label class="beyond_gastos_etiqueta">Buscar</label>
|
||||
<input type="search" class="beyond_gastos_campo"
|
||||
placeholder="Concepto…" t-on-input="onBuscar"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ══ Las tres cifras: el cruce, de entrada ══ -->
|
||||
<div class="beyond_gastos_cifras" t-if="state.datos">
|
||||
<div class="beyond_gastos_cifra">
|
||||
<span class="beyond_gastos_cifra_titulo">Total gastado</span>
|
||||
<span class="beyond_gastos_cifra_valor" t-esc="dinero(state.datos.cifras.total)"/>
|
||||
<span class="beyond_gastos_cifra_pie" t-esc="state.datos.periodo.etiqueta"/>
|
||||
</div>
|
||||
<div class="beyond_gastos_cifra">
|
||||
<span class="beyond_gastos_cifra_titulo">Operación</span>
|
||||
<span class="beyond_gastos_cifra_valor" t-esc="dinero(state.datos.cifras.gastos)"/>
|
||||
<span class="beyond_gastos_cifra_pie">gastos capturados</span>
|
||||
</div>
|
||||
<div class="beyond_gastos_cifra">
|
||||
<span class="beyond_gastos_cifra_titulo">Mercancía</span>
|
||||
<span class="beyond_gastos_cifra_valor" t-esc="dinero(state.datos.cifras.inventario)"/>
|
||||
<span class="beyond_gastos_cifra_pie">entradas de inventario con costo</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ══ La dona: proporción por categoría, total al centro ══ -->
|
||||
<div class="beyond_gastos_bloque" t-if="state.datos and dona.length">
|
||||
<span class="beyond_gastos_bloque_titulo">¿En qué se fue?</span>
|
||||
<svg class="beyond_gastos_dona" viewBox="0 0 1000 300"
|
||||
preserveAspectRatio="xMidYMid meet" role="img"
|
||||
aria-label="Proporción del gasto por categoría">
|
||||
<t t-foreach="dona" t-as="arco" t-key="arco.clave">
|
||||
<path t-att-d="arco.d" t-att-fill="arco.color">
|
||||
<title t-esc="arco.etiqueta + ' · ' + arco.montoTexto + ' · ' + arco.porcentaje.toFixed(1) + '%'"/>
|
||||
</path>
|
||||
<!-- Etiquetas fijas con guía: en tablet no hay
|
||||
cursor que pasar por encima. -->
|
||||
<polyline t-att-points="arco.sx + ',' + arco.sy + ' ' + arco.ex + ',' + arco.ty + ' ' + arco.tx + ',' + arco.ty"
|
||||
fill="none" stroke="#C9C4BC" stroke-width="1"/>
|
||||
<text t-att-x="arco.tx" t-att-y="arco.ty - 4"
|
||||
t-att-text-anchor="arco.anclaje"
|
||||
class="beyond_gastos_dona_nombre" t-esc="arco.etiqueta"/>
|
||||
<text t-att-x="arco.tx" t-att-y="arco.ty + 12"
|
||||
t-att-text-anchor="arco.anclaje"
|
||||
class="beyond_gastos_dona_monto"
|
||||
t-esc="arco.montoTexto + ' · ' + arco.porcentaje.toFixed(1) + '%'"/>
|
||||
</t>
|
||||
<text x="500" y="145" text-anchor="middle"
|
||||
class="beyond_gastos_dona_total" t-esc="donaTotal"/>
|
||||
<text x="500" y="168" text-anchor="middle"
|
||||
class="beyond_gastos_dona_leyenda">total</text>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- ══ La lista, por mes con su suma ══ -->
|
||||
<div class="beyond_gastos_bloque" t-if="state.datos">
|
||||
<div t-if="!state.datos.filas.length" class="beyond_gastos_vacio">
|
||||
<i class="fa fa-inbox"/>
|
||||
<b>Sin gastos en este periodo</b>
|
||||
<span>Cambia el filtro, o captura el primero con «Nuevo gasto».</span>
|
||||
</div>
|
||||
<table t-else="" class="beyond_gastos_tabla">
|
||||
<thead>
|
||||
<tr>
|
||||
<t t-foreach="[['fecha','Fecha'],['concepto','Concepto'],['categoria_etiqueta','Categoría'],['sucursal','Sucursal'],['monto','Monto']]"
|
||||
t-as="columna" t-key="columna[0]">
|
||||
<th t-att-class="{ beyond_num: columna[0] === 'monto',
|
||||
beyond_ordenada: state.orden.campo === columna[0] }"
|
||||
t-on-click="() => this.ordenarPor(columna[0])">
|
||||
<t t-esc="columna[1]"/>
|
||||
<i t-if="state.orden.campo === columna[0]"
|
||||
t-att-class="'fa fa-caret-' + (state.orden.dir === 1 ? 'up' : 'down')"/>
|
||||
</th>
|
||||
</t>
|
||||
<th/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="grupos" t-as="grupo" t-key="grupo.mes">
|
||||
<tr class="beyond_gastos_grupo">
|
||||
<td colspan="4" t-esc="etiquetaMes(grupo.mes)"/>
|
||||
<td class="beyond_num" t-esc="dinero(grupo.suma)"/>
|
||||
<td/>
|
||||
</tr>
|
||||
<tr t-foreach="grupo.filas" t-as="fila" t-key="fila.id"
|
||||
class="beyond_gastos_fila"
|
||||
t-on-click="() => this.abrirPanel(fila)">
|
||||
<td t-esc="fila.fecha"/>
|
||||
<td>
|
||||
<t t-esc="fila.concepto"/>
|
||||
<i t-if="fila.recurrente" class="fa fa-refresh beyond_gastos_marca"
|
||||
title="Generado por un gasto recurrente"/>
|
||||
</td>
|
||||
<td t-esc="fila.categoria_etiqueta"/>
|
||||
<td t-esc="fila.sucursal"/>
|
||||
<td class="beyond_num" t-esc="dinero(fila.monto)"/>
|
||||
<td class="beyond_gastos_clip">
|
||||
<i t-if="fila.adjuntos" class="fa fa-paperclip"
|
||||
t-att-title="fila.adjuntos + ' archivo(s) adjunto(s)'"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="beyond_gastos_paginador"
|
||||
t-if="state.datos.total > state.datos.mostrados">
|
||||
<span t-esc="(state.datos.offset + 1) + '-' + (state.datos.offset + state.datos.mostrados) + ' de ' + state.datos.total"/>
|
||||
<button type="button" class="btn" t-att-disabled="!state.datos.offset"
|
||||
t-on-click="() => this.paginar(-1)"><i class="fa fa-chevron-left"/></button>
|
||||
<button type="button" class="btn"
|
||||
t-att-disabled="state.datos.offset + state.datos.mostrados >= state.datos.total"
|
||||
t-on-click="() => this.paginar(1)"><i class="fa fa-chevron-right"/></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ══ El cajón de recurrentes ══ -->
|
||||
<div class="beyond_gastos_bloque beyond_gastos_recurrentes"
|
||||
t-if="state.recurrentes !== null">
|
||||
<div class="beyond_gastos_bloque_encabezado">
|
||||
<span class="beyond_gastos_bloque_titulo">Gastos recurrentes</span>
|
||||
<span class="beyond_gastos_bloque_sub">Se generan solos cada mes, el día que digas.</span>
|
||||
<button type="button" class="btn beyond_gastos_secundario"
|
||||
t-on-click="prepararRecurrente">
|
||||
<i class="fa fa-plus"/> Programar uno
|
||||
</button>
|
||||
</div>
|
||||
<div t-if="state.nuevoRecurrente" class="beyond_gastos_recurrente_alta">
|
||||
<input type="text" class="beyond_gastos_campo" placeholder="Concepto (Renta del local…)"
|
||||
t-att-value="state.nuevoRecurrente.name"
|
||||
t-on-input="(ev) => this.escribirRecurrente('name', ev)"/>
|
||||
<input type="text" inputmode="decimal" class="beyond_gastos_campo beyond_num"
|
||||
placeholder="$ Monto" t-att-value="state.nuevoRecurrente.monto"
|
||||
t-on-input="(ev) => this.escribirRecurrente('monto', ev)"/>
|
||||
<select class="beyond_gastos_campo"
|
||||
t-on-change="(ev) => this.escribirRecurrente('dia', ev)">
|
||||
<t t-foreach="[...Array(28).keys()]" t-as="dia" t-key="dia">
|
||||
<option t-att-value="dia + 1"
|
||||
t-att-selected="state.nuevoRecurrente.dia === dia + 1"
|
||||
t-esc="'día ' + (dia + 1)"/>
|
||||
</t>
|
||||
</select>
|
||||
<select class="beyond_gastos_campo"
|
||||
t-on-change="(ev) => this.escribirRecurrente('categoria', ev)">
|
||||
<option t-foreach="state.datos.categorias" t-as="categoria"
|
||||
t-key="categoria.clave" t-att-value="categoria.clave"
|
||||
t-att-selected="state.nuevoRecurrente.categoria === categoria.clave"
|
||||
t-esc="categoria.etiqueta"/>
|
||||
</select>
|
||||
<select class="beyond_gastos_campo" t-if="state.datos.puede_elegir"
|
||||
t-on-change="(ev) => this.escribirRecurrente('branch_id', ev)">
|
||||
<option t-foreach="state.datos.sucursales" t-as="sucursal"
|
||||
t-key="sucursal.id" t-att-value="sucursal.id"
|
||||
t-att-selected="state.nuevoRecurrente.branch_id === sucursal.id"
|
||||
t-esc="sucursal.nombre"/>
|
||||
</select>
|
||||
<button type="button" class="btn beyond_gastos_nuevo"
|
||||
t-on-click="guardarRecurrente">Programar</button>
|
||||
</div>
|
||||
<div t-if="!state.recurrentes.length" class="beyond_gastos_vacio">
|
||||
<span>Nada programado todavía. La renta y la luz son las candidatas.</span>
|
||||
</div>
|
||||
<div t-foreach="state.recurrentes" t-as="recurrente" t-key="recurrente.id"
|
||||
class="beyond_gastos_recurrente"
|
||||
t-att-class="{ beyond_apagado: !recurrente.activo }">
|
||||
<span t-esc="recurrente.name"/>
|
||||
<span class="beyond_num" t-esc="dinero(recurrente.monto)"/>
|
||||
<span t-esc="'día ' + recurrente.dia"/>
|
||||
<span t-esc="recurrente.branch_id[1]"/>
|
||||
<button type="button" class="btn btn-sm"
|
||||
t-on-click="() => this.alternarRecurrente(recurrente)"
|
||||
t-esc="recurrente.activo ? 'Pausar' : 'Reactivar'"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ══ El panel corto: seis campos y guardar ══ -->
|
||||
<div t-if="state.panel" class="beyond_gastos_velo" t-on-click="cerrarPanel"/>
|
||||
<div t-if="state.panel" class="beyond_gastos_panel">
|
||||
<div class="beyond_gastos_panel_encabezado">
|
||||
<b t-esc="state.panel.id ? 'Editar gasto' : 'Nuevo gasto'"/>
|
||||
<button type="button" class="btn" t-on-click="cerrarPanel">×</button>
|
||||
</div>
|
||||
<label class="beyond_gastos_etiqueta">Concepto</label>
|
||||
<input type="text" class="beyond_gastos_campo"
|
||||
placeholder="Recibo de luz…"
|
||||
t-att-value="state.panel.name"
|
||||
t-on-input="(ev) => this.escribirPanel('name', ev)"/>
|
||||
<label class="beyond_gastos_etiqueta">Monto</label>
|
||||
<input type="text" inputmode="decimal"
|
||||
class="beyond_gastos_campo beyond_num"
|
||||
placeholder="$ 0.00" t-att-value="state.panel.monto"
|
||||
t-on-input="(ev) => this.escribirPanel('monto', ev)"/>
|
||||
<label class="beyond_gastos_etiqueta">Fecha</label>
|
||||
<input type="date" class="beyond_gastos_campo"
|
||||
t-att-value="state.panel.fecha" t-att-max="hoyIso"
|
||||
t-on-change="(ev) => this.escribirPanel('fecha', ev)"/>
|
||||
<t t-if="state.datos.puede_elegir">
|
||||
<label class="beyond_gastos_etiqueta">Sucursal</label>
|
||||
<select class="beyond_gastos_campo"
|
||||
t-on-change="(ev) => this.escribirPanel('branch_id', ev)">
|
||||
<option t-foreach="state.datos.sucursales" t-as="sucursal"
|
||||
t-key="sucursal.id" t-att-value="sucursal.id"
|
||||
t-att-selected="state.panel.branch_id === sucursal.id"
|
||||
t-esc="sucursal.nombre"/>
|
||||
</select>
|
||||
</t>
|
||||
<label class="beyond_gastos_etiqueta">Categoría</label>
|
||||
<select class="beyond_gastos_campo"
|
||||
t-on-change="(ev) => this.escribirPanel('categoria', ev)">
|
||||
<option t-foreach="state.datos.categorias" t-as="categoria"
|
||||
t-key="categoria.clave" t-att-value="categoria.clave"
|
||||
t-att-selected="state.panel.categoria === categoria.clave"
|
||||
t-esc="categoria.etiqueta"/>
|
||||
</select>
|
||||
|
||||
<!-- La factura, en el propio gasto. Adjuntar pide que el
|
||||
gasto exista: primero se guarda, después se anexa. -->
|
||||
<t t-if="state.panel.id">
|
||||
<label class="beyond_gastos_etiqueta">Archivos</label>
|
||||
<div t-foreach="state.adjuntos" t-as="adjunto" t-key="adjunto.id"
|
||||
class="beyond_gastos_adjunto">
|
||||
<a t-att-href="enlaceAdjunto(adjunto)" t-esc="adjunto.name"/>
|
||||
<button type="button" class="btn btn-sm"
|
||||
title="Quitar el archivo"
|
||||
t-on-click="() => this.quitarAdjunto(adjunto)">×</button>
|
||||
</div>
|
||||
<input type="file" class="beyond_gastos_campo"
|
||||
t-on-change="subirAdjunto"/>
|
||||
</t>
|
||||
<span t-else="" class="beyond_gastos_nota">
|
||||
Guarda el gasto y aquí mismo le adjuntas la factura.
|
||||
</span>
|
||||
|
||||
<div class="beyond_gastos_panel_acciones">
|
||||
<button type="button" class="btn beyond_gastos_nuevo"
|
||||
t-att-disabled="!panelValido or state.guardando"
|
||||
t-on-click="() => this.guardarPanel(false)">Guardar</button>
|
||||
<button type="button" class="btn beyond_gastos_secundario"
|
||||
t-if="!state.panel.id"
|
||||
t-att-disabled="!panelValido or state.guardando"
|
||||
t-on-click="() => this.guardarPanel(true)">Guardar y otro</button>
|
||||
<span class="beyond_gastos_relleno"/>
|
||||
<button type="button" class="btn beyond_gastos_secundario"
|
||||
t-if="state.panel.id" t-on-click="abrirFicha"
|
||||
title="La ficha completa, con el historial de cambios">
|
||||
Abrir ficha
|
||||
</button>
|
||||
<button type="button" class="btn beyond_gastos_peligro"
|
||||
t-if="state.panel.id" t-on-click="borrarPanel">
|
||||
<i class="fa fa-trash-o"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div t-if="state.cargando and !state.datos" class="beyond_gastos_vacio">Cargando…</div>
|
||||
</div>
|
||||
</Layout>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -1,2 +1,4 @@
|
||||
from . import test_gastos
|
||||
from . import test_aislamiento_gastos
|
||||
from . import test_pantalla_gastos
|
||||
from . import test_pantalla_navegador
|
||||
@@ -0,0 +1,111 @@
|
||||
# Part of Beyond. Collina Systems proprietary module.
|
||||
"""La pantalla de Gastos: datos, alcance y descarga por la misma puerta."""
|
||||
import base64
|
||||
import io
|
||||
|
||||
import openpyxl
|
||||
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.beyond_branch.tests.common import BeyondBranchCase
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestBeyondPantallaGastos(BeyondBranchCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.Pantalla = self.env['beyond.gastos.pantalla'].with_user(
|
||||
self.admin_general)
|
||||
Gasto = self.env['beyond.gasto']
|
||||
self.renta = Gasto.create({
|
||||
'name': 'ZZ renta pantalla', 'monto': 1000.0,
|
||||
'fecha': '2026-09-04', 'branch_id': self.branch_a.id,
|
||||
'categoria': 'renta'})
|
||||
self.luz = Gasto.create({
|
||||
'name': 'ZZ luz pantalla', 'monto': 300.0,
|
||||
'fecha': '2026-09-05', 'branch_id': self.branch_a.id,
|
||||
'categoria': 'servicios'})
|
||||
producto = self.env['product.template'].create({
|
||||
'name': 'ZZ tinte pantalla', 'type': 'consu', 'sale_ok': True})
|
||||
self.env['beyond.movimiento'].beyond_entrada(
|
||||
producto, self.branch_a, 4, costo_unitario=250.0,
|
||||
fecha='2026-09-03 10:00:00')
|
||||
self.filtros = {'desde': '2026-09-01', 'hasta': '2026-09-30',
|
||||
'branch_id': self.branch_a.id}
|
||||
|
||||
def test_la_dona_reparte_exactamente_el_total(self):
|
||||
"""La regla de red de la pantalla: la dona y la cifra grande dicen el
|
||||
MISMO número — las categorías de operación más la mercancía como
|
||||
rebanada propia. Si divergen, alguien tiene que reconciliarlos de
|
||||
cabeza, que es justo lo que la pantalla existe para evitar."""
|
||||
datos = self.Pantalla.beyond_datos(self.filtros)
|
||||
self.assertEqual(sum(p['valor'] for p in datos['dona']),
|
||||
datos['cifras']['total'])
|
||||
claves = {p['clave'] for p in datos['dona']}
|
||||
self.assertIn('mercancia', claves, 'la mercancía es rebanada propia')
|
||||
self.assertIn('renta', claves)
|
||||
|
||||
def test_categoria_y_busqueda_recortan_la_lista_no_las_cifras(self):
|
||||
"""Deliberado: el total del periodo es el total del periodo. Filtrar
|
||||
la lista por «renta» no puede hacer que el negocio parezca gastar
|
||||
menos."""
|
||||
datos = self.Pantalla.beyond_datos(
|
||||
dict(self.filtros, categoria='renta'))
|
||||
self.assertEqual([f['concepto'] for f in datos['filas']],
|
||||
['ZZ renta pantalla'])
|
||||
self.assertEqual(datos['cifras']['gastos'], 1300.0,
|
||||
'las cifras siguen siendo del periodo completo')
|
||||
datos = self.Pantalla.beyond_datos(
|
||||
dict(self.filtros, busqueda='luz'))
|
||||
self.assertEqual([f['concepto'] for f in datos['filas']],
|
||||
['ZZ luz pantalla'])
|
||||
|
||||
def test_el_gerente_trabaja_en_su_plaza_y_la_ajena_es_error(self):
|
||||
pantalla = self.env['beyond.gastos.pantalla'].with_user(self.admin_a)
|
||||
datos = pantalla.beyond_datos({'desde': '2026-09-01',
|
||||
'hasta': '2026-09-30'})
|
||||
self.assertEqual(datos['sucursal']['id'], self.branch_a.id)
|
||||
self.assertFalse(datos['puede_elegir'])
|
||||
with self.assertRaises(AccessError):
|
||||
pantalla.beyond_datos({'branch_id': self.branch_b.id})
|
||||
|
||||
def test_el_renglon_dice_su_adjunto_y_su_origen(self):
|
||||
self.env['ir.attachment'].create({
|
||||
'name': 'factura.pdf', 'res_model': 'beyond.gasto',
|
||||
'res_id': self.renta.id, 'raw': b'%PDF-1.4 x'})
|
||||
plantilla = self.env['beyond.gasto.recurrente'].create({
|
||||
'name': 'ZZ programado', 'monto': 50.0, 'dia': 1,
|
||||
'categoria': 'renta', 'branch_id': self.branch_a.id})
|
||||
generado = self.env['beyond.gasto'].create({
|
||||
'name': 'ZZ generado', 'monto': 50.0, 'fecha': '2026-09-06',
|
||||
'branch_id': self.branch_a.id, 'categoria': 'renta',
|
||||
'recurrente_id': plantilla.id})
|
||||
filas = {f['concepto']: f
|
||||
for f in self.Pantalla.beyond_datos(self.filtros)['filas']}
|
||||
self.assertEqual(filas['ZZ renta pantalla']['adjuntos'], 1)
|
||||
self.assertEqual(filas['ZZ luz pantalla']['adjuntos'], 0)
|
||||
self.assertTrue(filas['ZZ generado']['recurrente'])
|
||||
self.assertFalse(filas['ZZ renta pantalla']['recurrente'])
|
||||
generado.unlink()
|
||||
|
||||
def test_el_excel_trae_el_periodo_completo_y_cuadra(self):
|
||||
"""El archivo dice lo mismo que la pantalla —los filtros se
|
||||
resuelven otra vez en el servidor— y trae el periodo COMPLETO, no
|
||||
la página que se veía."""
|
||||
archivo = self.Pantalla.beyond_descargar('xlsx', dict(self.filtros))
|
||||
libro = openpyxl.load_workbook(
|
||||
io.BytesIO(base64.b64decode(archivo['contenido'])))
|
||||
celdas = [c.value for hoja in libro.worksheets
|
||||
for fila in hoja.iter_rows() for c in fila]
|
||||
for esperado in ('ZZ renta pantalla', 'ZZ luz pantalla', 1000.0, 300.0):
|
||||
self.assertIn(esperado, celdas)
|
||||
datos = self.Pantalla.beyond_datos(self.filtros)
|
||||
self.assertIn(datos['cifras']['total'], celdas,
|
||||
'la cifra del resumen es la de la pantalla')
|
||||
|
||||
def test_el_pdf_sale_y_es_pdf(self):
|
||||
archivo = self.Pantalla.beyond_descargar('pdf', dict(self.filtros))
|
||||
self.assertTrue(base64.b64decode(
|
||||
archivo['contenido']).startswith(b'%PDF'))
|
||||
@@ -0,0 +1,80 @@
|
||||
# Part of Beyond. Collina Systems proprietary module.
|
||||
"""La pantalla de Gastos en un navegador de verdad: lo que un test de
|
||||
servidor daría por bueno sin poder verlo — que los filtros estén A LA
|
||||
VISTA, que las cifras y la dona se pinten, y que el panel corto abra."""
|
||||
from odoo.tests import HttpCase, tagged
|
||||
|
||||
from odoo.addons.beyond_branch.tests.ayudantes_navegador import AYUDANTES
|
||||
|
||||
ACCION = 'beyond_expense.action_beyond_gastos_pantalla'
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestBeyondGastosEnNavegador(HttpCase):
|
||||
|
||||
def test_la_pantalla_abre_mirando_y_el_panel_abre_corto(self):
|
||||
# Un gasto de HOY con dos categorías: la dona necesita qué repartir
|
||||
# sin depender de la fecha en que corra la suite.
|
||||
sucursal = self.env['beyond.branch'].search([], limit=1)
|
||||
for concepto, monto, categoria in (('AAA renta nav', 1000.0, 'renta'),
|
||||
('AAA luz nav', 300.0, 'servicios')):
|
||||
self.env['beyond.gasto'].create({
|
||||
'name': concepto, 'monto': monto, 'categoria': categoria,
|
||||
'branch_id': sucursal.id})
|
||||
self.browser_js(f"/odoo/action-{ACCION}",
|
||||
"""
|
||||
(async () => {
|
||||
""" + AYUDANTES + """
|
||||
await hasta('.o_beyond_gastos');
|
||||
await esperar(1800);
|
||||
|
||||
// ── Filtros a la vista, no en un desplegable ──
|
||||
seVe('.beyond_gastos_pastilla', 'los atajos de periodo');
|
||||
seVe('.beyond_gastos_buscador input', 'el buscador');
|
||||
|
||||
// ── Las tres cifras del cruce ──
|
||||
const cifras = document.querySelectorAll('.beyond_gastos_cifra');
|
||||
if (cifras.length !== 3) {
|
||||
throw new Error('deben ser tres cifras y hay ' + cifras.length);
|
||||
}
|
||||
seVe('.beyond_gastos_cifra_valor', 'la cifra grande');
|
||||
|
||||
// ── La dona se dibuja con datos ──
|
||||
const arcos = document.querySelectorAll('.beyond_gastos_dona path');
|
||||
if (arcos.length < 2) {
|
||||
throw new Error('la dona debe traer al menos dos rebanadas '
|
||||
+ '(hay ' + arcos.length + ')');
|
||||
}
|
||||
seVe('.beyond_gastos_dona_total', 'el total al centro');
|
||||
|
||||
// ── La lista agrupada, con el gasto sembrado ──
|
||||
const tabla = document.querySelector('.beyond_gastos_tabla');
|
||||
if (!tabla || !tabla.textContent.includes('AAA renta nav')) {
|
||||
throw new Error('el gasto sembrado no está en la lista');
|
||||
}
|
||||
// Desplazamiento EXPLÍCITO y con porqué (la regla de los
|
||||
// ayudantes): la lista vive debajo de la dona por diseño —
|
||||
// mirar primero, detalle después — así que llegar a ella
|
||||
// desplazando es el gesto real del usuario, no normalizar
|
||||
// un estado roto.
|
||||
document.querySelector('.beyond_gastos_grupo')
|
||||
.scrollIntoView({ block: 'center' });
|
||||
await esperar(400);
|
||||
seVe('.beyond_gastos_grupo', 'el grupo del mes con su suma');
|
||||
|
||||
// ── El panel corto: abre, y Guardar se apaga sin datos ──
|
||||
document.querySelector('.beyond_gastos_nuevo').click();
|
||||
await esperar(600);
|
||||
seVe('.beyond_gastos_panel', 'el panel de captura');
|
||||
const campos = document.querySelectorAll('.beyond_gastos_panel .beyond_gastos_campo');
|
||||
if (campos.length < 4) {
|
||||
throw new Error('el panel corto perdió campos: hay ' + campos.length);
|
||||
}
|
||||
const guardar = [...document.querySelectorAll('.beyond_gastos_panel button')]
|
||||
.find((b) => b.textContent.trim() === 'Guardar');
|
||||
if (!guardar || !guardar.disabled) {
|
||||
throw new Error('Guardar debe estar apagado con el panel vacío');
|
||||
}
|
||||
console.log('test successful');
|
||||
})();
|
||||
""", "", login='admin', timeout=180)
|
||||
@@ -92,16 +92,24 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- La pantalla propia (5-sep-2026): mirar cuánto se gastó es lo
|
||||
diario; capturar, lo ocasional. Acción cliente, como Inventario
|
||||
y el Histórico. -->
|
||||
<record id="action_beyond_gastos_pantalla" model="ir.actions.client">
|
||||
<field name="name">Gastos</field>
|
||||
<field name="tag">beyond_gastos</field>
|
||||
</record>
|
||||
|
||||
<!-- Entrada propia del Panel General, entre Catálogo (14) y
|
||||
Personal (16) — acordado el 4-sep (punto de contacto nº 2). -->
|
||||
Personal (16) — acordado el 4-sep (punto de contacto nº 2).
|
||||
Los dos hijos se fundieron (5-sep): los recurrentes son cajón
|
||||
de la propia pantalla. Las acciones de ventana de abajo siguen
|
||||
vivas: la de gastos es la puerta «abrir ficha» —el rastro de
|
||||
quién cambió qué vive en su chatter— y la de recurrentes, la
|
||||
de la cuenta técnica. -->
|
||||
<menuitem id="menu_beyond_gastos_raiz" name="Gastos"
|
||||
parent="beyond_branch.menu_beyond_root" sequence="15"
|
||||
action="action_beyond_gastos_pantalla"
|
||||
groups="beyond_base.beyond_group_admin_sucursal"/>
|
||||
<menuitem id="menu_beyond_gastos" name="Gastos del mes"
|
||||
parent="menu_beyond_gastos_raiz"
|
||||
action="action_beyond_gastos" sequence="10"/>
|
||||
<menuitem id="menu_beyond_gastos_recurrentes" name="Recurrentes"
|
||||
parent="menu_beyond_gastos_raiz"
|
||||
action="action_beyond_gastos_recurrentes" sequence="20"/>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in new issue
Block a user