chutinhha / tracmor

Automatically exported from code.google.com/p/tracmor
GNU General Public License v2.0
0 stars 0 forks source link

cannot delete some inventory items #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
some of the items in inventory cannot be deleted. Instead, i get the error
message below

This inventory model cannot be deleted because it is associated with one or
more transactions.

how can i delete such items?

Original issue reported on code.google.com by winston....@gmail.com on 18 Aug 2009 at 4:44

GoogleCodeExporter commented 9 years ago
I have encountered this on any Inventory item that has had a transaction 
associated with it, whether that be restocking, moving, taking out, etc. I 
suppose the argument could be made that this preserves an audit trail, so that 
you can see what transactions were taken on an item, even if that item is no 
longer in stock. Since pretty much every other field is editable, if you make 
an error, it should be correctable.

However, for testing purposes, this is a problem, as you don't want test items 
left in inventory. The only way I found to remove these items was to edit the 
table directly. Unfortunately, there's a bit of table traversal that you'll 
have to do to remove the rows without leaving dependencies on other tables. I 
believe you have to edit inventory_transaction, inventory_location and 
inventory_model in that order. That said, better practice would be to have 
separate instances of TracMor for testing and production.

Original comment by msmit...@gmail.com on 16 Jun 2010 at 10:29

GoogleCodeExporter commented 9 years ago
You can always change the ON DELETE to CASCADE.
In inventory_transaction change:
'inventory_location_id' to ON DELETE to CASCADE

In inventory_location change:
'inventory_model_id' to ON DELETE to CASCADE

You should then be able to remove Inventory that has transactions.

Original comment by bromley...@gmail.com on 25 Jun 2010 at 2:19