本文整理汇总了Python中tendenci.apps.invoices.models.Invoice.owner_id方法的典型用法代码示例。如果您正苦于以下问题:Python Invoice.owner_id方法的具体用法?Python Invoice.owner_id怎么用?Python Invoice.owner_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tendenci.apps.invoices.models.Invoice
的用法示例。
在下文中一共展示了Invoice.owner_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_invoice
# 需要导入模块: from tendenci.apps.invoices.models import Invoice [as 别名]
# 或者: from tendenci.apps.invoices.models.Invoice import owner_id [as 别名]
def save_invoice(self, *args, **kwargs):
status_detail = kwargs.get('status_detail', 'tendered')
admin_notes = kwargs.get('admin_notes', None)
object_type = ContentType.objects.get(app_label=self._meta.app_label,
model=self._meta.module_name)
try: # get invoice
invoice = Invoice.objects.get(
object_type = object_type,
object_id = self.pk,
)
except ObjectDoesNotExist: # else; create invoice
# cannot use get_or_create method
# because too many fields are required
invoice = Invoice()
invoice.object_type = object_type
invoice.object_id = self.pk
# primary registrant is responsible for billing
primary_registrant = self.registrant
invoice.bill_to_first_name = primary_registrant.first_name
invoice.bill_to_last_name = primary_registrant.last_name
invoice.bill_to_company = primary_registrant.company_name
invoice.bill_to_phone = primary_registrant.phone
invoice.bill_to_email = primary_registrant.email
invoice.bill_to_address = primary_registrant.address
invoice.bill_to_city = primary_registrant.city
invoice.bill_to_state = primary_registrant.state
invoice.bill_to_zip_code = primary_registrant.zip
invoice.bill_to_country = primary_registrant.country
invoice.creator_id = self.creator_id
invoice.owner_id = self.owner_id
# update invoice with details
invoice.title = "Registration %s for Event: %s" % (self.pk, self.event.title)
invoice.estimate = True
invoice.status_detail = status_detail
invoice.subtotal = self.amount_paid
invoice.total = self.amount_paid
invoice.balance = invoice.total
invoice.tender_date = datetime.now()
invoice.due_date = datetime.now()
invoice.ship_date = datetime.now()
invoice.admin_notes = admin_notes
invoice.save()
self.invoice = invoice
self.save()
return invoice