django-erp-framework icon indicating copy to clipboard operation
django-erp-framework copied to clipboard

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

Open im-nihal opened this issue 1 year ago • 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.

im-nihal avatar Dec 11 '23 11:12 im-nihal

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

RamezIssac avatar Dec 14 '23 09:12 RamezIssac

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

serg-it avatar Jan 22 '24 16:01 serg-it