From 73fa31abc8f34ae8e050707ce80e6d27ed68aa85 Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Tue, 25 Sep 2018 01:36:24 -0500 Subject: [PATCH] Mejora #278 --- source/app/models/main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/app/models/main.py b/source/app/models/main.py index 869875c..483e720 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -3303,10 +3303,18 @@ class Facturas(BaseModel): @classmethod def validate_count_partners(cls, ids): filters = (Facturas.id.in_(tuple(ids.keys()))) - partners = (Facturas.select(fn.COUNT(Facturas.cliente)) + # ~ partners = (Facturas.select(fn.COUNT(Facturas.cliente)) + # ~ .where(filters) + # ~ .group_by(Facturas.cliente) + # ~ .order_by(Facturas.cliente).tuples()) + # ~ if len(partners) > 1: + # ~ return False + # ~ return True + partners = (Facturas.select(fn.COUNT(Socios.rfc)) .where(filters) - .group_by(Facturas.cliente) - .order_by(Facturas.cliente).tuples()) + .join(Socios).switch(Facturas) + .group_by(Socios.rfc) + .order_by(Socios.rfc).tuples()) if len(partners) > 1: return False return True