Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error en el formulario de TaxPayer en referencia a certificate #173

Open
gusarg81 opened this issue Dec 20, 2022 · 6 comments
Open

Error en el formulario de TaxPayer en referencia a certificate #173

gusarg81 opened this issue Dec 20, 2022 · 6 comments

Comments

@gusarg81
Copy link

No estoy seguro si yo estoy cometiendo un error acá, pero como en cualquier formulario donde exista FILES, no tengo este tipo de errores al guardar (haya o no modificado el formulario).

Sin embargo en el formulario de TaxPayer que utilizo (nada custom, directo con ModelForm), al aplicar save() en el view (por más que no haya cambios en dicho formulario), me arroja:

Traceback (most recent call last):
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/gustavo/Desarrollo/Web/eBiller/ebiller/apps/management/views_settings.py", line 130, in settings_taxpayer_admin
taxpayer = taxpayer_form.save()
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/forms/models.py", line 548, in save
self.instance.save()
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/db/models/base.py", line 812, in save
self.save_base(
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/db/models/base.py", line 847, in save_base
pre_save.send(
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in
(receiver, receiver(signal=self, sender=sender, **named))
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django_afip/signals.py", line 11, in update_certificate_expiration
instance.certificate_expiration = instance.get_certificate_expiration()
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django_afip/models.py", line 423, in get_certificate_expiration
cert = self.certificate_object
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django_afip/models.py", line 412, in certificate_object
self.certificate.seek(0)
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/core/files/utils.py", line 46, in
seek = property(lambda self: self.file.seek)
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/db/models/fields/files.py", line 47, in _get_file
self._file = self.storage.open(self.name, "rb")
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/core/files/storage.py", line 40, in open
return self._open(name, mode)
File "/home/gustavo/Desarrollo/Web/eBiller/venv/lib/python3.10/site-packages/django/core/files/storage.py", line 276, in _open
return File(open(self.path(name), mode))
FileNotFoundError: [Errno 2] No such file or directory: '/home/gustavo/Desarrollo/Web/eBiller/ebiller/media/eBiller.crt'

El tema acá, más allá de que no estoy seguro por qué el error, es que la ruta del certificado es incorrecto acorde a lo que arroja la excepción FileNotFoundError (cuando en realidad es "/home/gustavo/Desarrollo/Web/eBiller/ebiller/media/afip/taxpayers/certs/eBiller.crt").

¿Qué estoy haciendo mal? ¿Mejor detectar los cambios de este formulario al guardar?

@WhyNotHugo
Copy link
Owner

WhyNotHugo commented Dec 20, 2022 via email

@gusarg81
Copy link
Author

Con taxpayer.certificate.read() no me dá ese error.

@WhyNotHugo
Copy link
Owner

WhyNotHugo commented Dec 20, 2022 via email

@gusarg81
Copy link
Author

Sin errores (devuelve 0).

@WhyNotHugo
Copy link
Owner

WhyNotHugo commented Dec 20, 2022 via email

@gusarg81
Copy link
Author

gusarg81 commented Dec 20, 2022

Nada grave en realidad, no creo tener que modificar un dato de ese formulario (salvo cuando se tenga que cambiar el Logo que está dentro del mismo formulario, sino lo separo).

Chas gracias por el tip.

EDIT: desconectando el Signal, vá bien.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants