+
+
+
-
- Debe quedar en
-
-
-
-
- Se registrará un ajuste de
-
.
+
+
+
+
+ Ahora hay
+
+
+
→
+
+
Debe quedar en
+
+ −
+
+
+ +
+
+
+
+
+
+
+
+
Motivo · obligatorio
+
+
+
+
+
+
+
+ Comentario (opcional)
+
+
+
+
+
+ Queda registrado quién lo ajustó, cuándo y por qué. Los
+ movimientos no se editan ni se borran.
+
+
+
+
+ Registrar ajuste
+
+ Cancelar
+
+
-
-
Motivo *
-
-
-
-
-
-
-
Comentario (opcional)
-
-
-
-
-
-
- Queda registrado quién lo ajustó, cuándo y por qué. Los
- movimientos no se editan ni se borran.
-
-
- Registrar ajuste
-
-
-
-
-
- Inventario
-
-
-
-
+
+
+
+
+
+
+
+ Historial
+
+
+ Existencia actual:
+
+ ·
+
+
+
×
+
-
-
-
-
-
-
entró en el periodo
-
-
-
-
-
-
salió en el periodo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Todos los motivos
-
-
-
+
-
- Sin movimientos en este periodo.
+
+ Sin movimientos en este periodo.
+
+
+
+
+
+
+
+
+
+ ·
+
+
+
+ Quedó en
+
+
+
+
+ Los movimientos no se editan ni se borran. Una corrección
+ se registra como un ajuste nuevo.
+
-
-
-
-
- Cuándo
- Movimiento
- Quién
- Cantidad
- Quedó en
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Los movimientos no se editan ni se borran. Una corrección
- se registra como un ajuste nuevo.
-
+
-
+
+
+
+
+
+ ← Inventario
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/beyond_inventory/tests/__init__.py b/addons/beyond_inventory/tests/__init__.py
index 6f00ff5..8a56ed1 100644
--- a/addons/beyond_inventory/tests/__init__.py
+++ b/addons/beyond_inventory/tests/__init__.py
@@ -1,3 +1,4 @@
from . import test_inventario
from . import test_pos_descuento
from . import test_pantallas
+from . import test_inventario_navegador
diff --git a/addons/beyond_inventory/tests/test_inventario_navegador.py b/addons/beyond_inventory/tests/test_inventario_navegador.py
new file mode 100644
index 0000000..f154ce7
--- /dev/null
+++ b/addons/beyond_inventory/tests/test_inventario_navegador.py
@@ -0,0 +1,346 @@
+# Part of Beyond. Collina Systems proprietary module.
+from odoo.tests import HttpCase, tagged
+
+from odoo.addons.beyond_branch.tests.ayudantes_navegador import AYUDANTES
+
+# El azul de inventario, unificado (#3D6A8A → rgb). Está escrito DOS veces a
+# propósito —aquí y en la regla de estilo—: si alguien mueve uno solo de los
+# dos, una de estas pruebas se pone roja y el par de azules no vuelve.
+AZUL = 'rgb(61, 106, 138)'
+
+ENTRAR = """
+ // Al inventario se entra por su mosaico del lanzador: es una
+ // app propia (la raíz nativa de stock con nuestra acción).
+ (await hasta('.beyond_block_inventario')).click();
+ await hasta('.o_beyond_inventario');
+ await esperar(2500);
+"""
+
+
+@tagged('post_install', '-at_install')
+class TestInventarioEnNavegador(HttpCase):
+ """La pantalla de existencias, como la ve una persona."""
+
+ def test_viste_el_panel_y_los_indicadores_no_son_filtros(self):
+ """Dos cosas que solo existen pintadas: la piel del panel —la raíz de
+ stock entró a APPS_PANEL por el mismo mecanismo que Tableros
+ (enmienda a ADR-013)— y que los indicadores son tres preguntas sobre
+ el mismo conjunto, no tres montones: un artículo con 1 de 4 está por
+ agotarse Y tiene existencia, así que no suman, no reparten y no
+ pueden ofrecerse como botones."""
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + ENTRAR + """
+ if (!document.body.classList.contains('beyond_panel')) {
+ throw new Error('Inventario no viste la piel del panel');
+ }
+ seVe('.beyond_inventario_titulo', 'el título');
+ seVe('.beyond_buscador input', 'el buscador');
+ seVe('.beyond_inventario_recibir', '«Recibir mercancía»');
+
+ const azul = getComputedStyle(
+ document.querySelector('.beyond_inventario_recibir'))
+ .backgroundColor;
+ if (azul !== '""" + AZUL + """') {
+ throw new Error('«Recibir mercancía» va en «' + azul
+ + '» y el azul de inventario es «""" + AZUL + """»');
+ }
+
+ const indicadores = [...document.querySelectorAll('.beyond_indicador')];
+ if (indicadores.length !== 3) {
+ throw new Error('hay ' + indicadores.length + ' indicadores');
+ }
+ for (const ind of indicadores) {
+ if (ind.tagName === 'BUTTON' || ind.closest('button')
+ || getComputedStyle(ind).cursor === 'pointer') {
+ throw new Error('un indicador se ofrece como botón: «'
+ + ind.textContent.trim().slice(0, 30) + '»');
+ }
+ }
+
+ // Cada renglón dice su estado con palabra, no solo con color.
+ const filas = document.querySelectorAll('.beyond_tabla_fila');
+ if (!filas.length) {
+ throw new Error('no hay renglones que mirar');
+ }
+ for (const fila of [...filas].slice(0, 10)) {
+ if (!fila.querySelector('.beyond_tabla_estado').textContent.trim()) {
+ throw new Error('un renglón sin estado escrito');
+ }
+ }
+ console.log('test successful');
+ })();
+ """, "", login='admin', timeout=180)
+
+ def test_el_gerente_no_elige_plaza(self):
+ """`puede_elegir` ya lo dice: al gerente no le viaja la de nadie más,
+ así que no hay selector que ofrecerle — solo el nombre de la suya."""
+ gerente = self.env['res.users'].search([]).filtered(
+ lambda u: u.branch_ids
+ and u.has_group('beyond_base.beyond_group_admin_sucursal')
+ and not u.has_group('beyond_base.beyond_group_admin_general'))[:1]
+ if not gerente:
+ self.skipTest('no hay gerente de sucursal con plaza en esta base')
+ gerente.sudo().write({'password': gerente.login})
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + ENTRAR + """
+ if (document.querySelector('select.beyond_inventario_plaza')) {
+ throw new Error('al gerente le sale el selector de plaza');
+ }
+ seVe('.beyond_inventario_plaza_fija', 'el nombre de su plaza');
+ console.log('test successful');
+ })();
+ """, "", login=gerente.login, timeout=180)
+
+ def test_el_boton_de_la_ficha_lleva_el_mismo_azul(self):
+ """La otra mitad del par: «Registrar existencias» en la ficha del
+ producto marca la salida del catálogo hacia inventario y lleva EL
+ azul —el único de la aplicación—. Nació #446888 y el diseño trajo
+ #3D6A8A; se unificó, y esto lo deja fijado."""
+ producto = self.env['product.template'].create({
+ 'name': 'AAA producto del azul', 'type': 'consu',
+ 'sale_ok': True, 'available_in_pos': True, 'list_price': 100.0})
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + """
+ (await hasta('[data-menu-xmlid="beyond_branch.menu_beyond_root"]')).click();
+ (await hasta('[data-menu-xmlid="beyond_branch.menu_beyond_catalogo"]')).click();
+ await hasta('.o_beyond_catalogo_hub');
+ await esperar(1500);
+ document.querySelectorAll('.beyond_hub_mosaico')[0].click();
+ await hasta('.o_beyond_catalogo_matriz');
+ await esperar(1500);
+ document.querySelector('.beyond_cat_tabla tbody tr .beyond_cat_fija').click();
+ await hasta('.beyond_boton_existencias');
+ await esperar(1000);
+
+ const azul = getComputedStyle(
+ document.querySelector('.beyond_boton_existencias'))
+ .backgroundColor;
+ if (azul !== '""" + AZUL + """') {
+ throw new Error('«Registrar existencias» va en «' + azul
+ + '» y el azul de inventario es «""" + AZUL + """»');
+ }
+ console.log('test successful');
+ })();
+ """, "", login='admin', timeout=180)
+
+ def test_recibir_escanea_suma_y_dice_por_que_no_puede_confirmar(self):
+ """Tres cosas que solo existen usándola: el foco arranca en el campo
+ de escaneo —se trabaja con un lector en la mano—, escanear dos veces
+ el mismo artículo SUMA sobre su renglón —duplicarlo haría que
+ «Quedará» mintiera y nadie lo notaría hasta contar el anaquel— y el
+ botón apagado lleva su razón al lado."""
+ articulo = self.env['product.template'].create({
+ 'name': 'AAA caja de navegador', 'type': 'consu', 'sale_ok': True,
+ 'available_in_pos': True, 'list_price': 90.0,
+ 'barcode': '7500000000917'})
+ self.assertTrue(articulo.barcode)
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + ENTRAR + """
+ (await hasta('.beyond_inventario_recibir')).click();
+ await hasta('.beyond_recibir_hoja');
+ await esperar(2500);
+
+ const campo = document.querySelector('.beyond_escaneo input');
+ if (document.activeElement !== campo) {
+ throw new Error('el foco no arranca en el campo de escaneo');
+ }
+ // Nada agregado: el botón está apagado y dice por qué.
+ if (!document.querySelector('.beyond_boton_azul').disabled) {
+ throw new Error('se puede confirmar una entrada vacía');
+ }
+ if (!document.querySelector('.beyond_pie_acciones .beyond_razon')) {
+ throw new Error('el botón apagado no dice por qué');
+ }
+
+ // Se escanea DOS veces el mismo código.
+ const escanear = async (codigo) => {
+ campo.value = codigo;
+ campo.dispatchEvent(new KeyboardEvent(
+ 'keydown', { key: 'Enter', bubbles: true }));
+ await esperar(2000);
+ };
+ await escanear('7500000000917');
+ await escanear('7500000000917');
+
+ const filas = document.querySelectorAll('.beyond_entrada_fila');
+ if (filas.length !== 1) {
+ throw new Error('escanear dos veces hizo ' + filas.length
+ + ' renglones en vez de sumar en uno');
+ }
+ const llegaron = Number(
+ document.querySelector('.beyond_entrada_cantidad').value);
+ if (llegaron !== 2) {
+ throw new Error('el renglón dice ' + llegaron + ' y llegaron 2');
+ }
+ if (document.querySelector('.beyond_boton_azul').disabled) {
+ throw new Error('con un artículo dentro sigue sin poder confirmarse');
+ }
+ console.log('test successful');
+ })();
+ """, "", login='admin', timeout=180)
+
+ def test_recibir_avisa_con_el_texto_del_servidor(self):
+ """Un código que no está en el catálogo no es un error de quien
+ escanea: se le dice qué hacer. El texto lo escribe el servidor y aquí
+ no se reescribe — dos redacciones para lo mismo se separan sin que
+ nadie se entere."""
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + ENTRAR + """
+ (await hasta('.beyond_inventario_recibir')).click();
+ await hasta('.beyond_recibir_hoja');
+ await esperar(2500);
+
+ const antes = document.querySelectorAll('.beyond_catalogo_fila').length;
+ const campo = document.querySelector('.beyond_escaneo input');
+ campo.value = '000-no-esta-en-el-catalogo';
+ campo.dispatchEvent(new KeyboardEvent(
+ 'keydown', { key: 'Enter', bubbles: true }));
+ await esperar(2500);
+
+ const aviso = document.querySelector('.beyond_escaneo_aviso');
+ if (!aviso) {
+ throw new Error('un código desconocido no avisa nada');
+ }
+ if (!aviso.textContent.includes('000-no-esta-en-el-catalogo')
+ || !aviso.textContent.includes('dirección')) {
+ throw new Error('el aviso no es el del servidor: «'
+ + aviso.textContent.trim() + '»');
+ }
+ // Y el catálogo sigue ahí: es de donde se sigue trabajando.
+ if (document.querySelectorAll('.beyond_catalogo_fila').length !== antes) {
+ throw new Error('el escaneo fallido se llevó el catálogo por delante');
+ }
+ console.log('test successful');
+ })();
+ """, "", login='admin', timeout=180)
+
+ def test_ajustar_marca_el_motivo_y_dice_la_diferencia(self):
+ """El chip elegido tiene que verse a un metro: es el mismo patrón que
+ falló en «Nivel de acceso» con dos grises casi iguales. Y la
+ diferencia se dice en palabras, que «bajan 4» se entiende sin haber
+ aprendido qué significa el ámbar."""
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + ENTRAR + """
+ document.querySelector('.beyond_tabla_fila .beyond_ajuste').click();
+ await hasta('.beyond_ajustar_hoja');
+ await esperar(1500);
+
+ // Sin cambio: apagado, y con su razón.
+ if (!document.querySelector('.beyond_boton_azul').disabled) {
+ throw new Error('se puede registrar un ajuste sin cambio');
+ }
+ const razon = document.querySelector('.beyond_pie_acciones .beyond_razon');
+ if (!razon || !razon.textContent.trim()) {
+ throw new Error('el botón apagado no dice por qué');
+ }
+ const frase = () => document.querySelector(
+ '.beyond_ajustar_diferencia').textContent;
+ if (!frase().includes('No hay cambio')) {
+ throw new Error('sin cambio, la frase dice «' + frase() + '»');
+ }
+
+ // Se sube uno: la frase cambia, pero falta el motivo.
+ document.querySelectorAll('.beyond_ajustar_paso1')[1].click();
+ await esperar(600);
+ if (!frase().includes('Suben')) {
+ throw new Error('al subir, la frase dice «' + frase() + '»');
+ }
+ if (!document.querySelector('.beyond_boton_azul').disabled) {
+ throw new Error('se puede ajustar sin motivo');
+ }
+
+ // Se elige motivo: el chip tiene que DISTINGUIRSE.
+ const motivos = [...document.querySelectorAll('.beyond_motivo')];
+ if (motivos.length < 2) {
+ throw new Error('los motivos no llegaron del servidor');
+ }
+ motivos[0].click();
+ await esperar(600);
+ const puesto = document.querySelector('.beyond_motivo.beyond_activo');
+ if (!puesto) {
+ throw new Error('el motivo elegido no se marca');
+ }
+ const otro = document.querySelector('.beyond_motivo:not(.beyond_activo)');
+ const fondoPuesto = getComputedStyle(puesto).backgroundColor;
+ if (fondoPuesto === getComputedStyle(otro).backgroundColor) {
+ throw new Error('el motivo elegido se ve igual que el resto: '
+ + fondoPuesto);
+ }
+ if (fondoPuesto !== '""" + AZUL + """') {
+ throw new Error('el motivo elegido va en «' + fondoPuesto
+ + '» y debe ir en el azul de inventario');
+ }
+ if (document.querySelector('.beyond_boton_azul').disabled) {
+ throw new Error('con cambio y motivo sigue sin poder registrarse');
+ }
+ console.log('test successful');
+ })();
+ """, "", login='admin', timeout=180)
+
+ def test_el_historial_es_un_cajon_sobre_la_lista(self):
+ """Se consulta para entender UN renglón, así que la lista se queda
+ debajo: sacarla obligaba a volver a encontrar el artículo al cerrar.
+ Se cierra con la × y tocando fuera, y cada movimiento dice en cuánto
+ quedó — es lo que deja seguir la cuenta hacia atrás."""
+ self.browser_js(
+ "/odoo",
+ """
+ (async () => {
+""" + AYUDANTES + ENTRAR + """
+ document.querySelector('.beyond_tabla_acciones button').click();
+ await hasta('.beyond_cajon');
+ await esperar(1500);
+
+ if (!document.querySelector('.beyond_cajon_fondo')) {
+ throw new Error('el cajón no oscurece lo de detrás');
+ }
+ if (!document.querySelector('.beyond_tabla_fila')) {
+ throw new Error('el cajón se llevó la lista por delante');
+ }
+ const movs = [...document.querySelectorAll('.beyond_movimiento')];
+ if (!movs.length) {
+ throw new Error('esta prueba necesita un artículo con movimientos');
+ }
+ for (const mov of movs) {
+ if (!mov.querySelector('.beyond_movimiento_resultante')) {
+ throw new Error('un movimiento no dice en cuánto quedó');
+ }
+ }
+
+ // Se cierra tocando fuera.
+ document.querySelector('.beyond_cajon_fondo').click();
+ await esperar(900);
+ if (document.querySelector('.beyond_cajon')) {
+ throw new Error('tocar fuera no cierra el cajón');
+ }
+
+ // Y con la ×.
+ document.querySelector('.beyond_tabla_acciones button').click();
+ await hasta('.beyond_cajon');
+ await esperar(1200);
+ document.querySelector('.beyond_cajon_cerrar').click();
+ await esperar(900);
+ if (document.querySelector('.beyond_cajon')) {
+ throw new Error('la × no cierra el cajón');
+ }
+ console.log('test successful');
+ })();
+ """, "", login='admin', timeout=180)