Closed Ruudjhuu closed 1 year ago
@Ruudjhuu can you please provide a minimum working example of a .csv
file which causes this issue?
Of course, here are the files you need to be able to reproduce. I only substituted sensitive information.
Probably need to change the path to the nginx configuration. docker-compose.yaml.txt
Hi today I ran into the same problem, but I think I have some additional information that could help find/fix this... More file formats have this problem, it is not just CSV. I have also tested XLS and XLSX...
I wanted to explore this in my development environment, therefore I needed to dump my own "production" DB which is postgresql on docker (just like that of the OP) and import it into sqlite. The problem disapeared... Both "production" and development versions are on release 0.10 dev. Therefore, it seems that the problem is DB specific.
Additionally, it seems to be specific to some DB rows. When I export all parts from the postgresql file and immediately try to import it... it fails on a few rows... but not all...
Hope this helps to fix this problem (as the Part import wizard also seems broken - will make a separate issue for that)
@bloemp interesting - can you share any more detailed information on the particular database rows that seem to be failing? Maybe there is something particular about those rows...
@SchrodingersGat as far as i can tell right now, the rows themself (working/non working) don't seem to be particular different. My knowledge lacks at this point but as the stacktrace mentions the distinct funtion, and the django documentation explicitly mentions postgresql for some sort of behaviour... this could be somehow related. Never the less I will try to make a small test case downsizing my postgresql db to a minimum so you can investigate... but it will take me a few days.
@SchrodingersGat well faster than expected... I have produced 2 files. One is the result of a datadump command from InvenTree running with the postgresql db that is completely stripped of data except for 2 parts and the part categories that they belong to. The second file is a CSV export of the parts from the admin page. If you try to import the CSV back again with a postgresql db you will get the exception... Loading the same datadump.json file into an InvenTree instance with a sqlite db (development env). Then try to import the CSV file, it works flawlessly.
Thanks @bloemp I think that this file helped me to find the bug
I'm finding this bug in Inventree 0.15.3. Same error message:
Can't pickle <function QuerySet.distinct at 0x7fb2bc4762a0>: it's not the same object as django.db.models.query.QuerySet.distinct
I exported a CSV of all parts, then trimmed back to just the first part, and tried re-importing the same file, and this error pops up. If I export a block, edit, and re-import, I get one error per line in the import.
Other version info:
InvenTree-Version: 0.15.3 Django Version: 4.2.12 Commit Hash: d4d9aa9 Commit Date: 2024-05-27
Database: postgresql Debug-Mode: False Deployed using Docker: True Platform: Linux-5.15.0-107-generic-x86_64-with Installer: DOC
Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.0.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}]
Update: I reviewed all of the part data and I can't see any issues with the re-imported part, the changes I make in the CSV before re-importing seem to be incorporated (tried changing IPN and Revision) and there doesn't seem to be any bad data anywhere. So maybe this is just an erroneous error message?
@motusRP can you provide a full stack trace for the error?
You should be able to see this error in the admin interface - https://docs.inventree.org/en/stable/settings/logs/
Please verify that this bug has NOT been raised before.
Describe the bug*
When exporting a parts csv and then importing it with changes or new content a error pops up with:
PicklingError: Can't pickle <function QuerySet.distinct at 0x7fd500b17c10>: it's not the same object as django.db.models.query.QuerySet.distinct
Steps to Reproduce
InvenTree Admin -> Home > Part > Parts > Export
csv
and clickSUBMIT
InvenTree Admin -> Home > Part > Parts > Import
csv
SUBMIT
Expected behavior
Data is imported and new/changed parts are available in the gui.
Deployment Method
Version Information
Version Information:
InvenTree-Version: 0.8.4 Django Version: 3.2.15 Commit Hash: ca1fbf9 Commit Date: 2022-10-20 Database: postgresql Debug-Mode: False Deployed using Docker: True
Relevant log output