Integra: el historial de cargas del almacén
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
commit
076077772c
6 files changed
+450
-18
No files matched your search
@@ -423,6 +423,111 @@ class BeyondInventarioPantalla(models.AbstractModel):
|
||||
['Beyond', 'Agotados', datos['sucursal']['nombre'],
|
||||
datos['mes']], formato))
|
||||
|
||||
# ── 3b · Historial general de cargas ────────────────────────────────
|
||||
# El historial por artículo cuenta la vida de UNO; este cuenta la del
|
||||
# almacén: todas las entradas del mes en la plaza, con su costo, quién
|
||||
# las recibió y su factura. Sin él, para saber qué entró en agosto había
|
||||
# que abrir artículo por artículo (8-sep).
|
||||
|
||||
@api.model
|
||||
def beyond_cargas(self, mes, branch_id=None):
|
||||
sucursal = self._beyond_sucursal(branch_id)
|
||||
desde, tope = self._beyond_mes_limites(mes)
|
||||
entradas = self.env['beyond.movimiento'].search([
|
||||
('branch_id', '=', sucursal.id), ('tipo', '=', 'entrada'),
|
||||
('fecha', '>=', desde), ('fecha', '<', tope),
|
||||
], order='fecha desc, id desc')
|
||||
|
||||
adjuntos = {}
|
||||
for adj in self.env['ir.attachment'].search_read(
|
||||
[('res_model', '=', 'beyond.movimiento'),
|
||||
('res_id', 'in', entradas.ids)], ['res_id', 'name']):
|
||||
adjuntos.setdefault(adj['res_id'], []).append(
|
||||
{'id': adj['id'], 'nombre': adj['name']})
|
||||
|
||||
filas, total, piezas, sin_costo = [], 0.0, 0.0, 0
|
||||
for m in entradas:
|
||||
con_costo = m.costo_unitario > 0
|
||||
importe = m.cantidad * m.costo_unitario if con_costo else None
|
||||
filas.append({
|
||||
'id': m.id,
|
||||
'fecha': self._beyond_cuando_largo(m.fecha),
|
||||
'articulo': m.product_tmpl_id.name,
|
||||
'cantidad': m.cantidad,
|
||||
'costo': m.costo_unitario if con_costo else None,
|
||||
'importe': importe,
|
||||
'quien': m.user_id.name,
|
||||
'nota': m.nota or '',
|
||||
'adjuntos': adjuntos.get(m.id, []),
|
||||
})
|
||||
piezas += m.cantidad
|
||||
if con_costo:
|
||||
total += importe
|
||||
else:
|
||||
sin_costo += 1
|
||||
return {'sucursal': {'id': sucursal.id, 'nombre': sucursal.name},
|
||||
'mes': mes, 'filas': filas,
|
||||
'resumen': {'total': total, 'piezas': piezas,
|
||||
'cargas': len(filas), 'sin_costo': sin_costo},
|
||||
'sucursales': [{'id': b.id, 'nombre': b.name}
|
||||
for b in self._beyond_sucursales_elegibles()]}
|
||||
|
||||
@api.model
|
||||
def beyond_cargas_descarga(self, mes, formato, branch_id=None):
|
||||
if formato not in ('xlsx', 'pdf'):
|
||||
raise UserError(_('Formato de descarga no reconocido.'))
|
||||
datos = self.beyond_cargas(mes, branch_id)
|
||||
resumen = datos['resumen']
|
||||
contexto = {
|
||||
'encabezado': {
|
||||
'titulo': _('Beyond · Cargas de almacén'),
|
||||
'datos': [(_('Mes'), datos['mes']),
|
||||
(_('Sucursal'), datos['sucursal']['nombre'])],
|
||||
'generado': self._beyond_generado(),
|
||||
'iva': self._beyond_aviso_iva(),
|
||||
},
|
||||
'cifras': [
|
||||
{'etiqueta': _('Costo de lo ingresado'),
|
||||
'texto': f"${resumen['total']:,.2f}",
|
||||
'valor': resumen['total'], 'formato': 'dinero'},
|
||||
{'etiqueta': _('Cargas'), 'texto': str(resumen['cargas']),
|
||||
'valor': resumen['cargas'], 'formato': 'entero'},
|
||||
{'etiqueta': _('Piezas'), 'texto': str(resumen['piezas']),
|
||||
'valor': resumen['piezas'], 'formato': 'decimal'},
|
||||
{'etiqueta': _('Cargas sin costo'),
|
||||
'texto': str(resumen['sin_costo']),
|
||||
'valor': resumen['sin_costo'], 'formato': 'entero'},
|
||||
],
|
||||
'bloques': [{
|
||||
'titulo': _('Cargas de %s', datos['mes']),
|
||||
'columnas': [
|
||||
{'etiqueta': _('Fecha'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Artículo'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Piezas'), 'formato': 'decimal'},
|
||||
{'etiqueta': _('Costo unitario'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Importe'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Quién'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Nota'), 'formato': 'texto'},
|
||||
{'etiqueta': _('Factura'), 'formato': 'texto'},
|
||||
],
|
||||
'filas': [[
|
||||
f['fecha'], f['articulo'], f['cantidad'],
|
||||
(f"${f['costo']:,.2f}" if f['costo'] is not None
|
||||
else _('sin costo registrado')),
|
||||
(f"${f['importe']:,.2f}" if f['importe'] is not None
|
||||
else '—'),
|
||||
f['quien'], f['nota'],
|
||||
', '.join(a['nombre'] for a in f['adjuntos']) or '—',
|
||||
] for f in datos['filas']],
|
||||
'grafica': None,
|
||||
}],
|
||||
}
|
||||
return self._beyond_archivo(
|
||||
contexto, formato,
|
||||
self._beyond_nombre_archivo(
|
||||
['Beyond', 'Cargas', datos['sucursal']['nombre'],
|
||||
datos['mes']], formato))
|
||||
|
||||
# ── 4 · Historial ───────────────────────────────────────────────────
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -49,6 +49,9 @@ export class BeyondInventario extends Component {
|
||||
// agotados del mes
|
||||
agotados: null,
|
||||
mesAgotados: new Date().toISOString().slice(0, 7),
|
||||
// historial general de cargas del almacén
|
||||
cargas: null,
|
||||
mesCargas: new Date().toISOString().slice(0, 7),
|
||||
descargando: false,
|
||||
// historial
|
||||
historial: null,
|
||||
@@ -144,30 +147,67 @@ export class BeyondInventario extends Component {
|
||||
}
|
||||
this.state.descargando = true;
|
||||
try {
|
||||
const archivo = await this.orm.call(
|
||||
this.guardarArchivo(await this.orm.call(
|
||||
"beyond.inventario", "beyond_agotados_descarga",
|
||||
[this.state.mesAgotados, formato, this.state.filtros.branch_id]);
|
||||
// El archivo llega en base64 por ORM; el navegador lo guarda
|
||||
// (mismo camino que el tablero y el histórico del POS).
|
||||
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);
|
||||
[this.state.mesAgotados, formato, this.state.filtros.branch_id]));
|
||||
} finally {
|
||||
this.state.descargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Historial general de cargas: lo que ENTRÓ al almacén en el mes ──
|
||||
// El historial por artículo cuenta la vida de uno; este la del almacén
|
||||
// entero (8-sep).
|
||||
|
||||
async abrirCargas() {
|
||||
this.state.pantalla = "cargas";
|
||||
await this.cargarCargas();
|
||||
}
|
||||
|
||||
async cargarCargas() {
|
||||
this.state.cargas = await this.orm.call(
|
||||
"beyond.inventario", "beyond_cargas",
|
||||
[this.state.mesCargas, this.state.filtros.branch_id]);
|
||||
}
|
||||
|
||||
async cambiarMesCargas(ev) {
|
||||
this.state.mesCargas = ev.target.value;
|
||||
await this.cargarCargas();
|
||||
}
|
||||
|
||||
async descargarCargas(formato) {
|
||||
if (this.state.descargando) {
|
||||
return;
|
||||
}
|
||||
this.state.descargando = true;
|
||||
try {
|
||||
this.guardarArchivo(await this.orm.call(
|
||||
"beyond.inventario", "beyond_cargas_descarga",
|
||||
[this.state.mesCargas, formato, this.state.filtros.branch_id]));
|
||||
} finally {
|
||||
this.state.descargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** El archivo llega en base64 por ORM; el navegador lo guarda (mismo
|
||||
* camino que el tablero y el histórico del POS). */
|
||||
guardarArchivo(archivo) {
|
||||
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);
|
||||
}
|
||||
|
||||
async abrirRecepcion() {
|
||||
this.state.recibiendo = [];
|
||||
this.state.nota = "";
|
||||
@@ -504,6 +544,11 @@ export class BeyondInventario extends Component {
|
||||
minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
dinero(valor) {
|
||||
return `$${(valor || 0).toLocaleString("es-MX", {
|
||||
minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
}
|
||||
|
||||
conSigno(valor) {
|
||||
return `${valor > 0 ? "+" : ""}${this.numero(valor)}`;
|
||||
}
|
||||
|
||||
@@ -1116,3 +1116,34 @@ body.beyond_panel_azul {
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
.beyond_cargas_eje,
|
||||
.beyond_cargas_fila {
|
||||
display: grid;
|
||||
grid-template-columns: 0.9fr 1.6fr 0.5fr 0.7fr 0.7fr 0.8fr 1.2fr;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
.beyond_cargas_resumen {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
padding: 12px 16px;
|
||||
margin-bottom: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid $inv-linea;
|
||||
border-radius: 12px;
|
||||
b { font-weight: 600; margin-right: 6px; }
|
||||
}
|
||||
// Sin costo se DICE, nunca $0 (ADR-029): ámbar, no un número falso.
|
||||
.beyond_cargas_sin_costo,
|
||||
.beyond_cargas_sin_costo_celda {
|
||||
color: #b26a00;
|
||||
font-style: italic;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.beyond_cargas_nota {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
@@ -76,6 +76,11 @@
|
||||
t-on-click="abrirAgotados">
|
||||
<i class="fa fa-calendar-times-o"/>Agotados del mes
|
||||
</button>
|
||||
<button type="button" class="beyond_inventario_agotados_btn"
|
||||
t-on-click="abrirCargas">
|
||||
<i class="fa fa-truck"/>Historial de cargas
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div t-if="state.cargando and !state.datos" class="beyond_inventario_vacio">
|
||||
@@ -198,6 +203,90 @@
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<!-- ══ 1c · Historial general de cargas ══
|
||||
El historial por artículo cuenta la vida de UNO; este la del
|
||||
almacén: todo lo que entró en el mes, con su costo, quién lo
|
||||
recibió y su factura (8-sep). Sin costo se DICE, nunca $0. -->
|
||||
<t t-if="state.pantalla === 'cargas'">
|
||||
<div class="beyond_inventario_encabezado">
|
||||
<button type="button" class="beyond_volver"
|
||||
t-on-click="volver">
|
||||
<i class="fa fa-arrow-left"/> Inventario
|
||||
</button>
|
||||
<span class="beyond_inventario_titulo">Historial de cargas</span>
|
||||
<input type="month" class="beyond_agotados_mes"
|
||||
t-att-value="state.mesCargas"
|
||||
t-on-change="cambiarMesCargas"/>
|
||||
<span class="beyond_agotados_relleno"/>
|
||||
<button type="button" class="btn beyond_agotados_descarga"
|
||||
t-att-disabled="state.descargando"
|
||||
t-on-click="() => this.descargarCargas('xlsx')">
|
||||
<i class="fa fa-file-excel-o"/> Excel
|
||||
</button>
|
||||
<button type="button" class="btn beyond_agotados_descarga"
|
||||
t-att-disabled="state.descargando"
|
||||
t-on-click="() => this.descargarCargas('pdf')">
|
||||
<i class="fa fa-file-pdf-o"/> PDF
|
||||
</button>
|
||||
</div>
|
||||
<div t-if="!state.cargas" class="beyond_inventario_vacio">Cargando…</div>
|
||||
<t t-else="">
|
||||
<div class="beyond_cargas_resumen">
|
||||
<span><b>Costo de lo ingresado</b>
|
||||
<t t-esc="dinero(state.cargas.resumen.total)"/></span>
|
||||
<span><b>Cargas</b> <t t-esc="state.cargas.resumen.cargas"/></span>
|
||||
<span><b>Piezas</b> <t t-esc="numero(state.cargas.resumen.piezas)"/></span>
|
||||
<span t-if="state.cargas.resumen.sin_costo"
|
||||
class="beyond_cargas_sin_costo"
|
||||
t-esc="state.cargas.resumen.sin_costo + ' sin costo'"/>
|
||||
</div>
|
||||
<div t-if="!state.cargas.filas.length" class="beyond_inventario_vacio">
|
||||
<i class="fa fa-inbox"/>
|
||||
<b>No entró mercancía este mes</b>
|
||||
<span>Ninguna carga en <t t-esc="state.cargas.sucursal.nombre"/>
|
||||
durante <t t-esc="state.cargas.mes"/>.</span>
|
||||
</div>
|
||||
<div t-else="" class="beyond_tabla">
|
||||
<div class="beyond_tabla_eje beyond_cargas_eje">
|
||||
<span>Cuándo</span>
|
||||
<span>Artículo</span>
|
||||
<span class="beyond_eje_derecha">Piezas</span>
|
||||
<span class="beyond_eje_derecha">Costo u.</span>
|
||||
<span class="beyond_eje_derecha">Importe</span>
|
||||
<span>Quién</span>
|
||||
<span>Nota y factura</span>
|
||||
</div>
|
||||
<t t-foreach="state.cargas.filas" t-as="fila" t-key="fila.id">
|
||||
<div class="beyond_tabla_fila beyond_cargas_fila">
|
||||
<span t-esc="fila.fecha"/>
|
||||
<span class="beyond_tabla_nombre" t-esc="fila.articulo"/>
|
||||
<span class="beyond_eje_derecha" t-esc="numero(fila.cantidad)"/>
|
||||
<t t-if="fila.costo !== null">
|
||||
<span class="beyond_eje_derecha" t-esc="dinero(fila.costo)"/>
|
||||
<span class="beyond_eje_derecha" t-esc="dinero(fila.importe)"/>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<span class="beyond_eje_derecha beyond_cargas_sin_costo_celda">
|
||||
sin costo registrado
|
||||
</span>
|
||||
<span class="beyond_eje_derecha">—</span>
|
||||
</t>
|
||||
<span t-esc="fila.quien"/>
|
||||
<span class="beyond_cargas_nota">
|
||||
<t t-esc="fila.nota"/>
|
||||
<a t-foreach="fila.adjuntos" t-as="adj" t-key="adj.id"
|
||||
class="beyond_movimiento_adjunto"
|
||||
t-att-href="'/web/content/' + adj.id + '?download=true'"
|
||||
t-att-title="adj.nombre">
|
||||
<i class="fa fa-paperclip"/>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<!-- ══ 2 · Recibir mercancía ══ -->
|
||||
<t t-if="state.pantalla === 'recibir'">
|
||||
<t t-call="beyond_inventory.InventarioMigas">
|
||||
|
||||
@@ -6,6 +6,7 @@ import io
|
||||
|
||||
import openpyxl
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import AccessError, UserError
|
||||
from odoo.tests import tagged
|
||||
|
||||
@@ -110,3 +111,118 @@ class TestBeyondAgotados(BeyondBranchCase):
|
||||
'2026-09', 'pdf', self.branch_a.id)
|
||||
crudo = base64.b64decode(archivo['contenido'])
|
||||
self.assertTrue(crudo.startswith(b'%PDF'), 'el contenido es un PDF')
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestBeyondHistorialDeCargas(BeyondBranchCase):
|
||||
"""Lo que ENTRÓ al almacén en el mes, de una plaza: el historial por
|
||||
artículo cuenta la vida de uno, este la del almacén entero (8-sep)."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.Pantalla = self.env['beyond.inventario'].with_user(
|
||||
self.admin_general)
|
||||
self.Movimiento = self.env['beyond.movimiento']
|
||||
self.tinte = self.env['product.template'].create({
|
||||
'name': 'ZZ tinte cargas', 'type': 'consu', 'sale_ok': True})
|
||||
self.gel = self.env['product.template'].create({
|
||||
'name': 'ZZ gel cargas', 'type': 'consu', 'sale_ok': True})
|
||||
|
||||
def _cargas_de(self, datos, nombre):
|
||||
return [f for f in datos['filas'] if f['articulo'] == nombre]
|
||||
|
||||
def test_trae_las_cargas_del_mes_con_su_costo_y_su_importe(self):
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.tinte, self.branch_a, 6, costo_unitario=250.0,
|
||||
fecha='2026-08-10 10:00:00')
|
||||
# De otro mes: no debe salir.
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.tinte, self.branch_a, 4, costo_unitario=200.0,
|
||||
fecha='2026-07-30 10:00:00')
|
||||
datos = self.Pantalla.beyond_cargas('2026-08', self.branch_a.id)
|
||||
filas = self._cargas_de(datos, 'ZZ tinte cargas')
|
||||
self.assertEqual(len(filas), 1, 'solo la carga de agosto')
|
||||
self.assertEqual(filas[0]['cantidad'], 6)
|
||||
self.assertEqual(filas[0]['costo'], 250.0)
|
||||
self.assertEqual(filas[0]['importe'], 1500.0)
|
||||
|
||||
def test_la_salida_no_es_carga_y_la_plaza_ajena_no_se_cuela(self):
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.gel, self.branch_a, 3, costo_unitario=100.0,
|
||||
fecha='2026-08-05 10:00:00')
|
||||
self.Movimiento.create({
|
||||
'product_tmpl_id': self.gel.id, 'branch_id': self.branch_a.id,
|
||||
'tipo': 'venta', 'cantidad': -1, 'fecha': '2026-08-06 10:00:00'})
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.gel, self.branch_b, 9, costo_unitario=100.0,
|
||||
fecha='2026-08-07 10:00:00')
|
||||
datos = self.Pantalla.beyond_cargas('2026-08', self.branch_a.id)
|
||||
filas = self._cargas_de(datos, 'ZZ gel cargas')
|
||||
self.assertEqual([f['cantidad'] for f in filas], [3.0],
|
||||
'ni la venta ni la carga de la plaza b')
|
||||
|
||||
def test_sin_costo_se_dice_y_no_suma(self):
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.tinte, self.branch_a, 5, costo_unitario=40.0,
|
||||
fecha='2026-08-03 10:00:00')
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.gel, self.branch_a, 7, fecha='2026-08-04 10:00:00')
|
||||
datos = self.Pantalla.beyond_cargas('2026-08', self.branch_a.id)
|
||||
sin = self._cargas_de(datos, 'ZZ gel cargas')[0]
|
||||
self.assertIsNone(sin['costo'])
|
||||
self.assertIsNone(sin['importe'])
|
||||
self.assertEqual(datos['resumen']['sin_costo'], 1)
|
||||
self.assertEqual(datos['resumen']['total'], 200.0,
|
||||
'lo sin costo no infla el total')
|
||||
self.assertEqual(datos['resumen']['piezas'], 12.0)
|
||||
self.assertEqual(datos['resumen']['cargas'], 2)
|
||||
|
||||
def test_la_factura_de_la_recepcion_viaja_con_su_carga(self):
|
||||
"""Se recibe por la MISMA puerta que el navegador, con factura."""
|
||||
self.Pantalla.beyond_recibir(
|
||||
[{'id': self.tinte.id, 'cantidad': 2, 'costo': 300.0}],
|
||||
branch_id=self.branch_a.id, nota='ZZ nota de carga',
|
||||
adjunto={'nombre': 'factura-zz.pdf',
|
||||
'datas': base64.b64encode(b'%PDF-1.4 zz').decode()})
|
||||
mes = fields.Date.context_today(self.Pantalla).strftime('%Y-%m')
|
||||
datos = self.Pantalla.beyond_cargas(mes, self.branch_a.id)
|
||||
fila = self._cargas_de(datos, 'ZZ tinte cargas')[0]
|
||||
self.assertEqual([a['nombre'] for a in fila['adjuntos']],
|
||||
['factura-zz.pdf'])
|
||||
self.assertIn('ZZ nota de carga', fila['nota'])
|
||||
|
||||
def test_el_gerente_ve_su_plaza_y_la_ajena_es_error(self):
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.tinte, self.branch_a, 2, costo_unitario=10.0,
|
||||
fecha='2026-08-02 10:00:00')
|
||||
pantalla = self.env['beyond.inventario'].with_user(self.admin_a)
|
||||
propias = pantalla.beyond_cargas('2026-08', self.branch_a.id)
|
||||
self.assertTrue(self._cargas_de(propias, 'ZZ tinte cargas'))
|
||||
with self.assertRaises(AccessError):
|
||||
pantalla.beyond_cargas('2026-08', self.branch_b.id)
|
||||
|
||||
def test_la_descarga_dice_lo_que_la_pantalla(self):
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.tinte, self.branch_a, 6, costo_unitario=250.0,
|
||||
fecha='2026-08-10 10:00:00')
|
||||
self.Movimiento.beyond_entrada(
|
||||
self.gel, self.branch_a, 7, fecha='2026-08-11 10:00:00')
|
||||
archivo = self.Pantalla.beyond_cargas_descarga(
|
||||
'2026-08', 'xlsx', self.branch_a.id)
|
||||
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 tinte cargas', 'ZZ gel cargas', '$250.00',
|
||||
'$1,500.00', 'sin costo registrado'):
|
||||
self.assertIn(esperado, celdas)
|
||||
datos = self.Pantalla.beyond_cargas('2026-08', self.branch_a.id)
|
||||
self.assertIn(datos['resumen']['total'], celdas)
|
||||
pdf = self.Pantalla.beyond_cargas_descarga(
|
||||
'2026-08', 'pdf', self.branch_a.id)
|
||||
self.assertTrue(base64.b64decode(pdf['contenido']).startswith(b'%PDF'))
|
||||
|
||||
def test_un_formato_inventado_no_se_descarga(self):
|
||||
with self.assertRaises(UserError):
|
||||
self.Pantalla.beyond_cargas_descarga('2026-08', 'docx',
|
||||
self.branch_a.id)
|
||||
@@ -344,3 +344,49 @@ class TestInventarioEnNavegador(HttpCase):
|
||||
console.log('test successful');
|
||||
})();
|
||||
""", "", login='admin', timeout=180)
|
||||
|
||||
def test_el_historial_de_cargas_dice_lo_que_entro_al_almacen(self):
|
||||
"""La otra mitad de Agotados: no lo que se acabó, lo que ENTRÓ. Se
|
||||
siembra una carga en cada plaza para que el mes en curso tenga qué
|
||||
enseñar sea cual sea la sucursal que abra la pantalla."""
|
||||
producto = self.env['product.template'].create({
|
||||
'name': 'ZZ crema navegador', 'type': 'consu', 'sale_ok': True})
|
||||
for sucursal in self.env['beyond.branch'].search([]):
|
||||
self.env['beyond.movimiento'].beyond_entrada(
|
||||
producto, sucursal, 3, costo_unitario=120.0,
|
||||
nota='ZZ carga de prueba')
|
||||
self.env.cr.flush()
|
||||
self.browser_js(
|
||||
"/odoo",
|
||||
"""
|
||||
(async () => {
|
||||
""" + AYUDANTES + ENTRAR + """
|
||||
const boton = [...document.querySelectorAll('button')].find(
|
||||
b => b.textContent.includes('Historial de cargas'));
|
||||
if (!boton) {
|
||||
throw new Error('no hay puerta al historial de cargas');
|
||||
}
|
||||
boton.click();
|
||||
await hasta('.beyond_cargas_eje');
|
||||
await esperar(1200);
|
||||
|
||||
seVe('.beyond_cargas_resumen', 'el resumen de lo ingresado');
|
||||
const tabla = document.querySelector('.beyond_tabla');
|
||||
if (!tabla.textContent.includes('ZZ crema navegador')) {
|
||||
throw new Error('la carga sembrada no está en el historial');
|
||||
}
|
||||
if (!tabla.textContent.includes('$120.00')
|
||||
|| !tabla.textContent.includes('$360.00')) {
|
||||
throw new Error('la carga no dice su costo y su importe');
|
||||
}
|
||||
seVe('.beyond_agotados_descarga', 'las descargas del historial');
|
||||
|
||||
// Y se vuelve a la lista, que es de donde se vino.
|
||||
document.querySelector('.beyond_volver').click();
|
||||
await esperar(900);
|
||||
if (!document.querySelector('.beyond_tabla_fila')) {
|
||||
throw new Error('volver no devuelve la lista de existencias');
|
||||
}
|
||||
console.log('test successful');
|
||||
})();
|
||||
""", "", login='admin', timeout=180)
|
||||
Reference in new issue
Block a user