def submit_success(self, appstruct): log.debug("Submitting cancelinvoice add") appstruct = get_cancel_invoice_dbdatas(appstruct) # Since the call to get_next_cancelinvoice_number commits the current # transaction, it needs to be called before creating our cancelinvoice, to # avoid missing arguments errors snumber = self.context.get_next_cancelinvoice_number() cinvoice = CancelInvoice() cinvoice.project = self.context cinvoice.owner = self.request.user cinvoice = merge_session_with_post(cinvoice, appstruct["cancelinvoice"]) cinvoice.set_sequence_number(snumber) cinvoice.set_number() cinvoice.set_name() try: cinvoice = self.set_task_status(cinvoice) cinvoice.invoice.check_resulted(user_id=self.request.user.id) self.dbsession.merge(cinvoice.invoice) # Line handling cinvoice = add_lines_to_cancelinvoice(cinvoice, appstruct) self.dbsession.add(cinvoice) self.dbsession.flush() self.session.flash(u"L'avoir a bien été ajoutée.") except Forbidden, err: self.request.session.flash(err.message, queue='error')
def cancelinvoice( dbsession, tva, unity, project, customer, company, user, phase, ): from autonomie.models.task.invoice import CancelInvoice cancelinvoice = CancelInvoice( company=company, project=project, customer=customer, user=user, phase=phase, ) dbsession.add(cancelinvoice) dbsession.flush() return cancelinvoice