I'd like to make sure I'm on the right track.

Given a standard Invoice/Work order type app, where one model is the
Work Order and one is Line Items.

When I save line items, I want to calculate extended price (Quantity *
cost). Put that in the Line Items model, def save()

After the line item is saved, I want to call the Work Order to have it
update a Total Due column. Assuming I have the code in the Work Order
model to get all the related line items and sum the extended price,
what I would do is call the Work Order save() method from the Line
Item save() methd, after calling the super(save).

That is:

class LineItems(models.Model):
    item = models.CharField(max_length=100)
    wo = models.ForeignKey(WorkOrder)

    def save(self):
        doLocalMath()
        super(LineItems, self).save()
        WorkOrder.save()

And, sort of related,  I need to call custom SQL to get the sum of
related records, correct?

Thanks.

 - Lee
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to