diff --git a/addons/beyond_branch/__manifest__.py b/addons/beyond_branch/__manifest__.py index 103f7e0..2008e32 100644 --- a/addons/beyond_branch/__manifest__.py +++ b/addons/beyond_branch/__manifest__.py @@ -25,6 +25,7 @@ Fase 1 — Arquitectura base (BRIEF §5.3 y §4): 'data/hide_account_menu.xml', 'data/menu_order.xml', 'data/pricelist_feature.xml', + 'data/hide_pos_catalog_menu.xml', 'views/beyond_branch_views.xml', 'views/res_users_views.xml', 'views/product_views.xml', diff --git a/addons/beyond_branch/data/hide_pos_catalog_menu.xml b/addons/beyond_branch/data/hide_pos_catalog_menu.xml new file mode 100644 index 0000000..d3f23f3 --- /dev/null +++ b/addons/beyond_branch/data/hide_pos_catalog_menu.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/addons/beyond_branch/security/ir.model.access.csv b/addons/beyond_branch/security/ir.model.access.csv index 4534eb4..1942afd 100644 --- a/addons/beyond_branch/security/ir.model.access.csv +++ b/addons/beyond_branch/security/ir.model.access.csv @@ -5,3 +5,7 @@ access_product_pricelist_admin_sucursal,product.pricelist edición de la propia access_product_pricelist_item_admin_sucursal,product.pricelist.item precios de su sucursal (admin sucursal),product.model_product_pricelist_item,beyond_base.beyond_group_admin_sucursal,1,1,1,1 access_product_pricelist_admin_general,product.pricelist gestión (admin general),product.model_product_pricelist,beyond_base.beyond_group_admin_general,1,1,1,1 access_product_pricelist_item_admin_general,product.pricelist.item gestión (admin general),product.model_product_pricelist_item,beyond_base.beyond_group_admin_general,1,1,1,1 +access_product_template_admin_sucursal,product.template catálogo (admin sucursal),product.model_product_template,beyond_base.beyond_group_admin_sucursal,1,1,1,0 +access_product_template_admin_general,product.template catálogo (admin general),product.model_product_template,beyond_base.beyond_group_admin_general,1,1,1,1 +access_product_product_admin_sucursal,product.product catálogo (admin sucursal),product.model_product_product,beyond_base.beyond_group_admin_sucursal,1,1,1,0 +access_product_product_admin_general,product.product catálogo (admin general),product.model_product_product,beyond_base.beyond_group_admin_general,1,1,1,1 diff --git a/addons/beyond_branch/tests/__init__.py b/addons/beyond_branch/tests/__init__.py index b79c12d..c98aac8 100644 --- a/addons/beyond_branch/tests/__init__.py +++ b/addons/beyond_branch/tests/__init__.py @@ -2,3 +2,4 @@ from . import test_isolation from . import test_provisioner from . import test_pricelist from . import test_disponibilidad +from . import test_catalogo diff --git a/addons/beyond_branch/tests/test_catalogo.py b/addons/beyond_branch/tests/test_catalogo.py new file mode 100644 index 0000000..ba3161b --- /dev/null +++ b/addons/beyond_branch/tests/test_catalogo.py @@ -0,0 +1,86 @@ +# Part of Beyond. Collina Systems proprietary module. +from odoo.exceptions import AccessError +from odoo.tests import tagged + +from .common import BeyondBranchCase + + +@tagged('post_install', '-at_install') +class TestBeyondCatalogoV0(BeyondBranchCase): + """Catálogo v0 provisional: menús, acciones y permisos con roles Beyond.""" + + def test_menu_visible_para_admin_de_sucursal(self): + Menu = self.env['ir.ui.menu'] + visibles = Menu.with_user(self.admin_a)._visible_menu_ids() + for xmlid in ('beyond_branch.menu_beyond_catalogo', + 'beyond_branch.menu_beyond_catalogo_productos', + 'beyond_branch.menu_beyond_catalogo_servicios'): + self.assertIn(self.env.ref(xmlid).id, visibles, xmlid) + + def test_productos_y_servicios_se_separan_por_tipo(self): + productos = self.env.ref('beyond_branch.action_beyond_catalogo_productos') + servicios = self.env.ref('beyond_branch.action_beyond_catalogo_servicios') + self.assertIn("('type', '=', 'consu')", productos.domain) + self.assertIn("('type', '=', 'service')", servicios.domain) + + def test_productos_no_deja_crear(self): + """El embudo de productos es Captura de productos, no el catálogo.""" + accion = self.env.ref('beyond_branch.action_beyond_catalogo_productos') + self.assertIn("'create': False", accion.context) + + def test_alta_de_servicio_nace_lista_para_el_pos(self): + """Los defaults de la acción son los que el POS pide para cargarlo.""" + accion = self.env.ref('beyond_branch.action_beyond_catalogo_servicios') + for esperado in ("'default_type': 'service'", + "'default_available_in_pos': True", + "'default_sale_ok': True"): + self.assertIn(esperado, accion.context) + + def test_admin_de_sucursal_da_de_alta_un_servicio(self): + contexto = {'default_type': 'service', 'default_available_in_pos': True, + 'default_sale_ok': True, 'default_is_storable': False} + servicio = self.env['product.template'].with_user(self.admin_a).with_context( + **contexto).create({'name': 'Servicio Del Gerente', 'list_price': 120.0}) + self.assertEqual(servicio.type, 'service') + self.assertTrue(servicio.available_in_pos) + # y el POS de su sucursal lo carga + dominio = self.env['product.template']._load_pos_data_domain( + {}, self.branch_a.pos_config_id) + self.assertIn(servicio, self.env['product.template'].search(dominio)) + + def test_admin_de_sucursal_no_borra_del_catalogo(self): + servicio = self.env['product.template'].create({ + 'name': 'Servicio Intocable', 'type': 'service'}) + with self.assertRaises(AccessError): + servicio.with_user(self.admin_a).unlink() + + def test_la_disponibilidad_solo_la_edita_el_admin_general(self): + """Decisión: branch_ids es estructura de red. En la ficha del catálogo + el admin de sucursal lo ve en solo lectura; es un guardia de interfaz, + no una regla de acceso.""" + arch = self.env.ref('beyond_branch.view_beyond_catalogo_form').arch + self.assertIn('groups="beyond_base.beyond_group_admin_general"', arch) + self.assertIn('groups="!beyond_base.beyond_group_admin_general"', arch) + self.assertIn('readonly="1"', arch) + + def test_precios_por_sucursal_se_abren_filtrados_al_producto(self): + accion = self.env.ref('beyond_branch.action_beyond_precios_por_sucursal') + self.assertEqual(accion.res_model, 'product.pricelist.item') + self.assertIn("('product_tmpl_id', '=', active_id)", accion.domain) + self.assertIn("'default_applied_on': '1_product'", accion.context) + + def test_la_entrada_nativa_del_pos_queda_escondida(self): + """Dos puertas al mismo dato es cómo se desincroniza la operación.""" + menu = self.env.ref('point_of_sale.menu_pos_products') + self.assertEqual(menu.group_ids, self.env.ref('base.group_no_one')) + self.assertNotIn( + menu.id, self.env['ir.ui.menu'].with_user(self.admin_a)._visible_menu_ids()) + + def test_captura_de_productos_sigue_en_pie(self): + """El catálogo no toca el embudo de captura (mudanza agendada aparte).""" + menu = self.env.ref('beyond_product_capture.menu_beyond_product_capture', + raise_if_not_found=False) + if not menu: + self.skipTest('beyond_product_capture no está instalado') + self.assertIn(menu.id, + self.env['ir.ui.menu'].with_user(self.admin_a)._visible_menu_ids()) diff --git a/addons/beyond_branch/views/product_views.xml b/addons/beyond_branch/views/product_views.xml index d8609a1..16a8d64 100644 --- a/addons/beyond_branch/views/product_views.xml +++ b/addons/beyond_branch/views/product_views.xml @@ -1,8 +1,13 @@ - + + + product.template.form.beyond.branch product.template @@ -15,4 +20,267 @@ + + + + beyond.catalogo.producto.list + product.template + + + + + + + + + + + + + + beyond.catalogo.servicio.list + product.template + + + + + + + + + + + + + + beyond.catalogo.producto.kanban + product.template + + + + + +
+ +
+
+ en existencia +
+
+
+
+
+
+
+ + + beyond.catalogo.servicio.kanban + product.template + + + + + +
+ +
+
+ Disponible en: + +
+
+
+
+
+
+
+ + + + beyond.precios.sucursal.list + product.pricelist.item + + + + + + + + + + + + + Precios por sucursal + product.pricelist.item + list + + [('product_tmpl_id', '=', active_id)] + { + 'default_product_tmpl_id': active_id, + 'default_applied_on': '1_product', + 'default_compute_price': 'fixed', + } + +

Sin precios especiales

+

Este artículo se vende en toda la red al precio base. Agrega un + renglón solo para la sucursal que cobre distinto.

+
+
+ + + + beyond.catalogo.form + product.template + +
+ +
+ +
+ +
+

+
+ + + + + + + + + + + + + + + +
+
+
+
+ + + + Productos + product.template + kanban,list,form + [('type', '=', 'consu')] + + {'create': False} + +

Todavía no hay productos

+

Los productos entran por Captura de productos, escaneando su + código de barras.

+
+
+ + + Servicios + product.template + kanban,list,form + [('type', '=', 'service')] + + { + 'default_type': 'service', + 'default_available_in_pos': True, + 'default_sale_ok': True, + 'default_is_storable': False, + } + +

Da de alta tu primer servicio

+

Nombre y precio base bastan. Si solo se ofrece en algunas + sucursales, márcalas en "Disponible en".

+
+
+ + + + + kanban + + + + + + list + + + + + + form + + + + + + kanban + + + + + + list + + + + + + form + + + + + +