diff --git a/addons/beyond_customer/demo/demo_clientes.xml b/addons/beyond_customer/demo/demo_clientes.xml index 6f808cb..c138e24 100644 --- a/addons/beyond_customer/demo/demo_clientes.xml +++ b/addons/beyond_customer/demo/demo_clientes.xml @@ -46,4 +46,24 @@ +52 222 900 1122 San Andrés Cholula + + + diff --git a/addons/beyond_customer/models/res_partner.py b/addons/beyond_customer/models/res_partner.py index 3eb127a..59ccca9 100644 --- a/addons/beyond_customer/models/res_partner.py +++ b/addons/beyond_customer/models/res_partner.py @@ -1,6 +1,12 @@ # Part of Beyond. Collina Systems proprietary module. +import logging + from odoo import _, api, fields, models +from odoo.addons.beyond_base.tools.arranque import ejecutar_en_arranque + +_logger = logging.getLogger(__name__) + # Estados de una orden de POS que cuentan como consumo real POS_ORDER_STATES = ('paid', 'done', 'invoiced') @@ -42,6 +48,54 @@ class ResPartner(models.Model): for partner in self: partner.beyond_es_cliente = partner.id in clientes + @api.model + def _beyond_demo_limpiar_contactos_hijos(self): + """DEMO ONLY: archives Odoo's sample contacts that hang off a company. + + Odoo's own demo data ships two dozen people attached to companies + (Floyd Steward at Acme Corporation and friends). They match the + Clientes domain — they are people, with no user and no employee — so + they crowd the screen with 33 records, show a breadcrumb reading + "Acme Corporation, Floyd Steward" and pull their parent's address + into the form. None of that would reach production, where a customer + is created from the POS with no parent, but it makes the screen + impossible to review. + + THE DOMAIN IS DELIBERATELY NOT TOUCHED. Excluding contacts with a + parent would have been the other way out, and it is a change to the + SALE path, not to a screen: _beyond_dominio_clientes also feeds the + POS in its two routes — the load domain and the stored + beyond_es_cliente the selector reads (beyond_pos_theme). A customer + who happens to be linked to a company would quietly disappear from + the cashier's selector, and the migrated customers of D4 are exactly + the ones that could arrive with such a link. A demo nuisance does not + justify that risk. + + Archived and not deleted: the records stay for whatever else in the + demo refers to them. Idempotent, and demo-only — this never runs in + production, where demo data is not installed. + """ + return ejecutar_en_arranque( + self.env, 'Limpieza de contactos demo de Odoo', + self._beyond_demo_archivar_hijos) + + @api.model + def _beyond_demo_archivar_hijos(self): + ruido = self.sudo().search( + self._beyond_dominio_clientes() + [('parent_id', '!=', False)]) + # Los de Beyond no tienen padre, así que no pueden caer aquí; el + # filtro extra es por si alguien agrega uno colgado de una compañía. + nuestros = self.env['ir.model.data'].sudo().search([ + ('model', '=', 'res.partner'), ('module', '=', 'beyond_customer'), + ]).mapped('res_id') + ruido = ruido.filtered(lambda p: p.id not in nuestros) + if ruido: + ruido.write({'active': False}) + _logger.warning( + 'Beyond · datos demo: %s contactos de ejemplo de Odoo archivados ' + 'para que no se mezclen con los clientes de Beyond.', len(ruido)) + return len(ruido) + beyond_visit_count = fields.Integer( string='Visitas', compute='_compute_beyond_metrics') beyond_last_visit = fields.Datetime( diff --git a/addons/beyond_customer/tests/test_clientes_vistas.py b/addons/beyond_customer/tests/test_clientes_vistas.py index c475277..e39e864 100644 --- a/addons/beyond_customer/tests/test_clientes_vistas.py +++ b/addons/beyond_customer/tests/test_clientes_vistas.py @@ -59,6 +59,37 @@ class TestClientesVistas(TransactionCase): 'email', campo.get('filter_domain') or '', "el buscador de Clientes sigue buscando por correo") + def test_no_queda_rastro_del_correo_en_ninguna_vista(self): + """No basta con quitar el campo: el renglón traía además un icono de + sobre, y un icono de correo en una pantalla donde el correo no existe + es exactamente el rastro que no debe quedar.""" + for xmlid in VISTAS: + arch = etree.fromstring(self._arch(xmlid)) + sobres = arch.xpath("//*[contains(@class, 'fa-envelope')]") + self.assertFalse(sobres, f"{xmlid} conserva el icono de correo") + + def test_la_ficha_no_lleva_chatter(self): + """Decisión del 24-ago. Solo en esta vista.""" + arch = etree.fromstring(self._arch('beyond_customer.view_beyond_cliente_form')) + self.assertFalse(arch.xpath('//chatter'), + "la ficha de Clientes conserva el chatter") + + def test_la_direccion_es_la_del_cliente_y_no_la_de_una_empresa(self): + """La etiqueta del bloque era el campo dinámico type_address_label, + que en un contacto colgado de una empresa dice «Dirección de la + empresa» y enseña la del padre.""" + arch = etree.fromstring(self._arch('beyond_customer.view_beyond_cliente_form')) + self.assertFalse(arch.xpath("//field[@name='type_address_label']"), + "la ficha sigue etiquetando la dirección con el campo dinámico") + self.assertFalse(arch.xpath("//field[@name='company_name']"), + "la ficha sigue ofreciendo la empresa del contacto") + + def test_la_ficha_permite_capturar_la_ciudad(self): + """La lista tiene columna Ciudad: si la ficha no la capturara, esa + columna solo podría llenarse por importación.""" + arch = etree.fromstring(self._arch('beyond_customer.view_beyond_cliente_form')) + self.assertTrue(arch.xpath("//field[@name='city']")) + def test_contactos_nativo_conserva_lo_suyo(self): """Las vistas primary existen justamente para no tocar lo nativo: la cuenta técnica sigue viendo un contacto completo.""" @@ -67,6 +98,8 @@ class TestClientesVistas(TransactionCase): "el formulario nativo de contacto perdió el correo") self.assertTrue(nativa.xpath("//field[@name='vat']"), "el formulario nativo de contacto perdió el RFC") + self.assertTrue(nativa.xpath('//chatter'), + "el formulario nativo de contacto perdió el chatter") # ── Lo que la ficha sí tiene, y lo que no ───────────────────────────── diff --git a/addons/beyond_customer/views/res_partner_views.xml b/addons/beyond_customer/views/res_partner_views.xml index 5ad894e..e6706a1 100644 --- a/addons/beyond_customer/views/res_partner_views.xml +++ b/addons/beyond_customer/views/res_partner_views.xml @@ -138,18 +138,40 @@ personas (is_company = False). --> - - + + - + + + + + + Dirección + + + + + + + @@ -192,6 +214,10 @@ + + +