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 + + + +
+
+
+
+
+