Closed arteme closed 11 years ago
What's the solution for this issue? Issue #25 mentions this issue in a somewhat different context, but is there a way to not use "plata.product.stock"?
oh, sorry, I've hit the submit button a bit too early....
To me it seems that the ForeignKey from StockTransaction to OrderPayment is the culprit. When Django's doing it's magic when deleting objects it encounters StockTransaction somehow regardless of the PLATA_STOCK_TRACKING setting.
Yes, I think that's correct. The stock models should be skipped if plata.product.stock
is NOT added to INSTALLED_APPS
. I'm not sure why this isn't happening.
@matthiask is there a workaround? What side-effects would it have to add plata.product.stock
to INSTALLED_APPS
? Do I have to manage stock items myself then?
Andi,
It should not have any side effects beneath the addition of two database tables. As long as PLATA_STOCK_TRACKING is False (which is the default) you should not have to change anything, especially not manage stock items yourself.
I'd still like to know why you are seeing this particular problem. I hope I'll be able to reproduce this issue.
Thanks, Matthias
Thanks for the feedback! I'll try it with plata.shop.stock
in INSTALLED_APPS
.
The problem is a bit weird to reproduce. It occurs in some of our testing instances from time to time, but I was not able to reproduce it on a development machine or even to repeat the behavior on a testing machine after it occurred. But I keep an eye on it and hope to come up with some more information when this happens, especially how Django comes to the conclusion, that it has to look at the stock model at some point.
FTR, when enabling stock
this way, the same problem with migrations as addressed in issue #26 comes up.
I've been finally hit by this issue too. Luckily, I'm able to reproduce it in the development server too...
This is probably a bug in Django: http://code.djangoproject.com/ticket/19422
The only place I found where the stock models are imported if PLATA_STOCK_TRACKING=False
was in the reporting module.
The bug can be triggered by importing plata.product.stock.models
early somewhere in a models file which is referenced through INSTALLED_APPS
.
I'm not sure whether there is an easy way to fix the problem without patching Django first. Maybe make the period and stock transaction model abstract?
Note: Same issue on a difference project... https://github.com/tomchristie/django-rest-framework/issues/705
Workaround for later reference:
https://github.com/tomchristie/django-rest-framework/commit/c5b98f0d106758298edf045e7bb44ecd7e4b9629
Hi,
If I have the settings as:
Then deleting orders fails:
If I add
"plata.product.stock"
toINSTALLED_APPS
then deletion succeeds.