Hi

I'm trying to post some docs to database, and have some issues associated 
that I'm not sure howto implement in django.

class DocNumber(models.Model):
    tipo=models.CharField(max_length=2)
   Year=models.IntegerField()
   Number=modelsIntegerField()

class Doc(models.Model):
   Tipo = models.CharField(max_length=2)
   Year=models.IntegerField()
   Number=modelsIntegerField()
    .....

class DocLine(models.Model):
    doc=ForeignKey(Doc)
    product=ForeignKey(Product)
    price=models.FloatField()
    .....


In my actual native app, when I save a document I've the following procedure

1.  start a transaction
2. if is a new doc get a new number from DocNumber increment that number 
(update lock this table to ensure no more docs with this number)
3. if is an update remove the old doc from stock (old lines)
4. save Doc and DocLines to DB
5. update the stock according to new lines
6. commit the transaction


I'm not able for the moment to implement this procedure in django, it seems 
to me that it should go in Doc save method, but  not sure how to get the 
number in a unique maner and update stocks accordingly?

Anyone has been trough the same problem, as this is a common pattern for me.

Kind Regards
Alexandre Rua





-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to