Coverage for apps/proxy_models/models.py: 80%
30 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-11-08 13:30 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-11-08 13:30 -0600
1from django.db import models
3from apps.proscai.models import Fcli, Falmcat, Fag
4from .managers import SalesmanManager, StoreManager, ClientManager
5from api.proscai.client import create_client, update_client
8class Client(Fcli):
9 class Meta:
10 proxy = True
11 ordering = ['clicod']
13 objects = ClientManager()
15 def __str__(self):
16 return " ".join([self.clinom, self.clicod])
19 def save(self, *args, **kwargs):
20 print('entre al save del modelo')
21 """
22 clicod = self.__dict__.get('clicod', None)
23 fields = [field.name for field in self._meta.fields]
24 kw = {}
25 for field in fields:
26 if self.__dict__.get(field):
27 kw[field] = self.__dict__.get(field, None)
28 else:
29 pass
31 if clicod:
32 print('entre al models ln 29')
33 try:
34 existing_client = Fcli.objects.get(clicod=clicod)
35 update_client(**kw)
36 except:
37 print('entre al save de models, tratare de crear al cliente')
38 print('kwargs', kw)
39 create_client(**kw)
40 else:
41 pass
42 """
47class Store(Falmcat):
48 class Meta:
49 proxy = True
50 ordering = ['catalm']
52 objects = StoreManager()
55 @property
56 def email(self):
57 related_client = Fcli.objects.filter(clicod=self.catalm).first()
58 if related_client:
59 related_client_email = related_client.clitel3
60 else:
61 related_client_email = None
62 return related_client_email
64 def __str__(self):
65 return ' '.join([self.catalm, self.catdescr]) or super().__str__()
69class Salesman(Fag):
70 class Meta:
71 proxy = True
72 ordering = ['agnum']
75 objects = SalesmanManager()
77 def __str__(self):
78 return self.agdescr or super().__str__()
81"""
82tienda
83vendedor
84ticket
85documento de cobro
86"""