dulacp / django-accounting

Accounting pluggable app for Django 1.7+ projects
MIT License
220 stars 100 forks source link

Should we replace get_field_by_name() by get_field() #7

Open NhaTrang opened 4 years ago

NhaTrang commented 4 years ago

Hi,

I am trying to upgrade this app. I`ve got one error when trying to create an invoice or bill:

Environment: Request Method: GET Request URL: http://127.0.0.1:8000/accounts/invoice/create/

Django Version: 3.0.7 Python Version: 3.8.3

Traceback (most recent call last):

  File "F:\Program Files\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "F:\Program Files\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "F:\Program Files\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "F:\Program Files\Python38-32\lib\site-packages\django\views\generic\base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "F:\Program Files\Python38-32\lib\site-packages\django\views\generic\base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "F:\Program Files\Python38-32\lib\site-packages\django\views\generic\edit.py", line 168, in get
    return super().get(request, *args, **kwargs)
  File "F:\Program Files\Python38-32\lib\site-packages\django\views\generic\edit.py", line 133, in get
    return self.render_to_response(self.get_context_data())
  File "F:\bawrak\bawrak\accounts\mixins.py", line 104, in get_context_data
    context = super().get_context_data(**kwargs)
  File "F:\Program Files\Python38-32\lib\site-packages\django\views\generic\edit.py", line 66, in get_context_data
    kwargs['form'] = self.get_form()
  File "F:\bawrak\bawrak\accounts\views.py", line 326, in get_form
    form = super().get_form(form_class)
  File "F:\bawrak\bawrak\accounts\mixins.py", line 121, in get_form
    self.restrict_fields_choices_to_organization(form, orga)
  File "F:\bawrak\bawrak\accounts\mixins.py", line 63, in restrict_fields_choices_to_organization
    self._restrict_fields_choices(model, organization, form.fields)
  File "F:\bawrak\bawrak\accounts\mixins.py", line 43, in _restrict_fields_choices
    field, m, direct, m2m = model._meta.get_fields(source)
  File "F:\Program Files\Python38-32\lib\site-packages\django\db\models\options.py", line 750, in get_fields
    return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
  File "F:\Program Files\Python38-32\lib\site-packages\django\db\models\options.py", line 766, in _get_fields
    raise TypeError("Invalid argument for include_parents: %s" % (include_parents,))

Exception Type: TypeError at /accounts/invoice/create/ Exception Value: Invalid argument for include_parents: number

Ive replacedget_field_by_name('client')byget_field('client'). Its just the beginning of many others issues but any idea on how to resolve this error please?

gigincg commented 3 years ago

Hey, where you able to make any progress in using this well with Django 3+ ?