RamezIssac/django-erp-framework

Inconsistent Method Resolution Order (MRO) in TimeSeriesSelectorReportView in views.py line 213

Opened this issue · 2 comments

Issue:

I think the class TimeSeriesSelectorReportView in django-erp-framework/erp_framework/reporting/views.py inherits from both UserPassesTestMixin and ReportViewBase in the wrong order. This results in a TypeError: Cannot create a consistent method resolution order (MRO) for bases error when attempting to runserver or migration.

Observed Behavior:

When running python manage.py migrate, the following error occurs:

Traceback (most recent call last):
...
..
..
...
File "/home/gedion/Desktop/ERP/virt/src/django-erp-framework/erp_framework/reporting/views.py", line 213, in <module>
class TimeSeriesSelectorReportView(UserPassesTestMixin, ReportViewBase):
TypeError: Cannot create a consistent method resolution order (MRO) for bases UserPassesTestMixin, ReportViewBase

Screenshot from 2023-12-11 17-26-25

Expected Behavior:
runserver and Migrations should run successfully without encountering any errors.

Proposed Solution:
The order of inheritance in TimeSeriesSelectorReportView should be reversed:

class TimeSeriesSelectorReportView(ReportViewBase, UserPassesTestMixin):

Screenshot from 2023-12-11 17-27-35

This ensures that methods from ReportViewBase are prioritized over those from UserPassesTestMixin, resolving the MRO conflict and allowing to the server and migrations to run successfully.

Additional Notes:
This issue was identified during development of the my-shop project.
The proposed solution was tested and confirmed to resolve the error.
This appears to be a bug in the django-erp-framework package.

Desired Outcome:
The developers of django-erp-framework address this bug in a future release. The documentation for django-erp-framework is updated to reflect the correct order of inheritance for TimeSeriesSelectorReportView.

Thank you for the report !
I will check and get back to you

Hi,
Class ReportViewBase inherits from UserPassesTestMixin that's why in class TimeSeriesSelectorReportView enough delete mixin UserPassesTestMixin