Hi

Off the top of my head (as in "do not use directly"!), it seems to me that:

1. You need a boolean field for 'serial' and also one for 'countable' for a 
Product.  One or both must be checked (use clean() to check) when Product 
is created.
2. Each Product also needs a 'status' field:  one of 'available', 'on loan' 
(and, perhaps, 'missing' or 'reserved')
3. I assume that an "Event" is an instance of a Product being lent out 
(that was not clear) with a one:Many to Products.  Each Event can then pull 
in Products as needed (but only from those that are 'available').  You 
could also have "planned" events that can "reserve" items.  A post-trigger 
on the Event save() can update the "status" field of each item and also 
make an entry to the ProductHistory (but its not clear at what point in the 
process a user would add comments??)
4.  Not sure why a Product cannot be effectively linked to a Warehouse via 
FK?  This should work as a Product cannot be in two places at the same time!
5. To move Products between Warehouses, I would use an action, with an 
intermediate page, in the Admin - see 
https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ and 
http://www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/
 
and https://gist.github.com/rturowicz/5472482

Your comment about "List of items (change_list in admin) shouldn't have 5 
items of serial+countable, just one" does not make sense. To do the 
one:many for an Event, you'd need to add Products, each of which should 
have its own serial number and status (i.e. serial number and status are 
NOT detached from a Product but part of the model.)

To be honest, you do not give enough details about the actual data, and 
user requirements, associated with every item (Product, Warehouse, Event) 
to really understand your scenario and create the best logic.

HTH though.


On Tuesday, 27 May 2014 01:43:29 UTC+2, Wojtas wrote:
>
> Hi there!
> I didn't know where to ask. I'm doing Django for couple of years, and I 
> encountered following problem.
>
> I'm doing a website which manages warehouse of company which lends music 
> instruments.
>
> I have 3 types of products:
> serial -> which exist only in amount of 1
> countable -> which exist in many amounts, like for example jack cable - 
> they don't need information which one is broken for instance, so just 
> information how many can we take
> *serial+countable* -> normally it doesn't matter which is which, in case 
> sth is lost or broken.
>
> I'm using of course django admin to manage the data. 
>
> Let's call the  warehouse product Stuff
> It's not a big problem to save the data and manage it, but I have some 
> specific requirements for serial+countable:
> 1. Reserve stuff for period of time. All 3 types in specific amount ( if 
> available at this time)
> 2. Move specific amount of items from one warehouse to another (for 
> instance one serial+countable object gets broken and we need to move them 
> to repair warehouse from main)
> 3. every serial+countable object should have own history of events + 
> comment history attached to it)
> 4. List of items (change_list in admin) shouldn't have 5 items of 
> serial+countable, just one, with listing of serial numbers and status of 
> each one of them inside the edit view.
>
>
> What I achieved so far:
> I have models:
> Stuff
> Event with M2M to Stuff which is through intermediate table with extra 
> count field. So I can check for two basic types of stuff how many are busy 
> at this time.
>
> So far there is no any definition of serial+countable in the models except 
> for char choice field.
>
> So there's a FK from Stuff to Warehouse model, which is not enough.
>
> I hope my problem description is complete. 
>
> Thank you for any help.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/da50d159-7417-4653-a316-639132bb36ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to