Skip to content

Instantly share code, notes, and snippets.

@shofetim
Created February 27, 2013 19:29
Show Gist options
  • Select an option

  • Save shofetim/5050884 to your computer and use it in GitHub Desktop.

Select an option

Save shofetim/5050884 to your computer and use it in GitHub Desktop.
def save(self, **kwargs):
self.flag_cached_attrs_as_stale()
self.react_to_purchasing_status()
if not self.id:
self.payment_term = self.vendor.payment_term
if self.freight_method in (FREIGHT_CC_FULL, FREIGHT_CC_LTL):
self.common_carrier_pickup_address = self.vendor.any_warehouse_contact
if self.common_carrier_pickup_address:
if(not self.common_carrier_pickup_address.the_same_address_as(self.historic_common_carrier_pickup_address)
and self.phase <= PHASE_RECEIVING):
ccpa = CommonCarrierPickupAddress()
ccpa.copy_address_from(self.common_carrier_pickup_address)
ccpa.save()
self.historic_common_carrier_pickup_address = ccpa
if self.vendor.vendorcontact_set.filter(contact_type='main').exists():
self.vendor_contact = self.vendor.vendorcontact_set.filter(contact_type='main')[0]
if self.vendor.vendorcontact_set.filter(contact_type='broker').exists():
self.broker_to_copy = self.vendor.vendorcontact_set.filter(contact_type='broker')[0]
super(Purchase, self).save(**kwargs)
self.update_lines_for_status()
@shofetim
Copy link
Copy Markdown
Author

This is from /apps/purchasing/models.py in the Purchase class

By the time we get to self.update_lines_for_status() we have purchase lines, but I don't see where they are created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment