def create(self, id): # yes, the swapping of id is confusing, thanks laziness # from default routes # id = name of the project # invoice.id = invoice number project_name = id project = Project.objects.get(name=project_name) invoice = Invoice(project=project, number=self.form_result['invoice_number'], bill_to=self.form_result['bill_to'], tax=self.form_result['tax'], date=datetime.datetime( self.form_result['date'].year, self.form_result['date'].month, self.form_result['date'].day, ), rate=project.rate) invoice.save() timesheets = Timesheet.objects(project=project, __raw__={'invoice': None}) for timesheet in timesheets: timesheet.archived_rate = timesheet.rate timesheet.invoice = invoice timesheet.save() return redirect( url(controller="invoice", action="summary", id=invoice.number))
def create(self, id): # yes, the swapping of id is confusing, thanks laziness # from default routes # id = name of the project # invoice.id = invoice number project_name = id project = Project.objects.get(name=project_name) invoice = Invoice( project=project, number=self.form_result["invoice_number"], bill_to=self.form_result["bill_to"], tax=self.form_result["tax"], date=datetime.datetime( self.form_result["date"].year, self.form_result["date"].month, self.form_result["date"].day ), rate=project.rate, ) invoice.save() timesheets = Timesheet.objects(project=project, __raw__={"invoice": None}) for timesheet in timesheets: timesheet.archived_rate = timesheet.rate timesheet.invoice = invoice timesheet.save() return redirect(url(controller="invoice", action="summary", id=invoice.number))