From 667b92fd14f8e536bdb178e0511b452aec162186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorem=20Ju=C3=A1rez?= Date: Wed, 19 Aug 2026 13:15:45 -0600 Subject: [PATCH] =?UTF-8?q?Cat=C3=A1logo=20=E2=86=92=20Productos=20recuper?= =?UTF-8?q?a=20su=20bot=C3=B3n=20'Nuevo',=20que=20abre=20la=20captura?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La lista nace con create: False a propósito (ADR-003: el alta de un producto pasa por el embudo de captura, que resuelve código de barras, base abierta, foto y existencias iniciales). Pero quedarse SIN botón dejó la pantalla como la única del sistema sin puerta de alta, y obligaba a saber que el alta vive en otro menú. Ahora el botón existe donde la gente lo busca y hace lo correcto: abre el embudo. Se añade como botón de cabecera en la lista y en el kanban del catálogo —el patrón del core para esto (stock lo usa con display=always)— y vive en este módulo, no en beyond_branch, porque la dependencia va en este sentido: la captura conoce al catálogo, no al revés. Un test verifica que el botón está en el arch REAL de ambas vistas y apunta a la captura, y otro que el alta directa sigue cerrada: una sola puerta. --- addons/beyond_product_capture/__manifest__.py | 1 + .../tests/test_capture.py | 30 +++++++++++- .../views/catalogo_boton_views.xml | 48 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 addons/beyond_product_capture/views/catalogo_boton_views.xml diff --git a/addons/beyond_product_capture/__manifest__.py b/addons/beyond_product_capture/__manifest__.py index a5d887b..e5f8af1 100644 --- a/addons/beyond_product_capture/__manifest__.py +++ b/addons/beyond_product_capture/__manifest__.py @@ -23,6 +23,7 @@ el respaldo foto+OCR (D5) se valida en el piloto — ver ADR-003. 'data': [ 'security/ir.model.access.csv', 'views/product_capture_views.xml', + 'views/catalogo_boton_views.xml', ], 'demo': [], 'installable': True, diff --git a/addons/beyond_product_capture/tests/test_capture.py b/addons/beyond_product_capture/tests/test_capture.py index 9ae4794..47fd4f8 100644 --- a/addons/beyond_product_capture/tests/test_capture.py +++ b/addons/beyond_product_capture/tests/test_capture.py @@ -2,7 +2,8 @@ from unittest.mock import patch from odoo.exceptions import AccessError, ValidationError -from odoo.tests import tagged +from odoo.tests import TransactionCase, tagged +from odoo.tools.safe_eval import safe_eval from odoo.addons.beyond_branch.tests.common import BeyondBranchCase from odoo.addons.beyond_product_capture.wizards.product_capture import BeyondProductCapture @@ -113,3 +114,30 @@ class TestBeyondProductCapture(BeyondBranchCase): wizard.action_scan() wizard.action_add_stock() self.assertEqual(self._stock_en(self.producto_existente, self.branch_b), 4.0) + + +@tagged('post_install', '-at_install') +class TestBeyondCatalogoBotonNuevo(TransactionCase): + """El "Nuevo" de Catálogo → Productos existe y abre el embudo de captura + (ADR-003), en vez de una segunda puerta que se lo saltaría.""" + + def _arch(self, xmlid_vista): + vista = self.env.ref(xmlid_vista) + return self.env['product.template'].get_view(vista.id, vista.type)['arch'] + + def test_el_boton_nuevo_abre_el_embudo_de_captura(self): + captura = self.env.ref('beyond_product_capture.action_beyond_product_capture') + for xmlid in ('beyond_branch.view_beyond_catalogo_producto_list', + 'beyond_branch.view_beyond_catalogo_producto_kanban'): + arch = self._arch(xmlid) + self.assertIn('
', arch, f'{xmlid} se quedó sin barra de acciones') + self.assertIn('Nuevo', arch, f'{xmlid} se quedó sin el botón de alta') + self.assertIn(str(captura.id), arch, + f'{xmlid}: el botón no apunta a la captura de productos') + + def test_sigue_habiendo_una_sola_puerta(self): + """El alta directa sigue cerrada: el botón lleva al embudo, no a un + formulario suelto que se saltaría código de barras y existencias.""" + accion = self.env.ref('beyond_branch.action_beyond_catalogo_productos') + self.assertIs(safe_eval(accion.context).get('create'), False, + 'la lista de productos no debe permitir el alta directa') diff --git a/addons/beyond_product_capture/views/catalogo_boton_views.xml b/addons/beyond_product_capture/views/catalogo_boton_views.xml new file mode 100644 index 0000000..caf7ea1 --- /dev/null +++ b/addons/beyond_product_capture/views/catalogo_boton_views.xml @@ -0,0 +1,48 @@ + + + + + beyond.catalogo.producto.list.captura + product.template + + + +
+
+
+
+
+ + + beyond.catalogo.producto.kanban.captura + product.template + + + +
+
+
+
+
+