Exemple #1
0
    def form_valid(self, form):
        data = form.cleaned_data
        client = Client(name=data.get("name"), qr_code=data.get("qr_code"))
        bank = Bank(bank=data.get("bank"), bic=data.get("bic"), iban=data.get("iban"))
        contact = Contact(company_image=data.get("company_image"), telefon=data.get("phone"), fax=data.get("fax"),
                          email=data.get("email"), website=data.get("website"),
                          website_conditions_link=data.get("website_conditions_link"),
                          commercial_register=data.get("commercial_register"), tax_number=data.get("tax_number"),
                          sales_tax_identification_number=data.get("sales_tax_identification_number"))
        billing_address = Adress(firma=data.get("billing_company"), strasse=data.get("billing_street"),
                                 hausnummer=data.get("billing_house_number"),
                                 place=data.get("billing_place"), zip=data.get("billing_zip"),
                                 vorname=data.get("billing_first_name"), nachname=data.get("billing_last_name"))

        delivery_address = Adress(firma=data.get("delivery_company"), strasse=data.get("delivery_street"),
                                  hausnummer=data.get("delivery_house_number"),
                                  place=data.get("delivery_place"), zip=data.get("delivery_zip"),
                                  vorname=data.get("delivery_first_name"), nachname=data.get("delivery_last_name"))

        try:
            billing_address.save()
            delivery_address.save()
            bank.save()
            contact.billing_address = billing_address
            contact.delivery_address = delivery_address
            contact.save()
            contact.bank.add(bank)
            contact.save()
            client.contact = contact
            client.save()
        except ValidationError as e:
            return render(self.request, self.template_name, self.get_context_data())
        return super().form_valid(form)
Exemple #2
0
 def save_new_supplier(self, billing_form, delivery_form):
     contact = Contact()
     billing_address = billing_form.save()
     delivery_address = delivery_form.save()
     contact.billing_address = billing_address
     contact.delivery_address = delivery_address
     contact.save()
     supplier = Supplier()
     supplier.contact = contact
     supplier.save()
Exemple #3
0
 def save_new_customer(self, billing_form, delivery_form):
     contact = Contact()
     billing_address = billing_form.save()
     delivery_address = delivery_form.save()
     contact.billing_address = billing_address
     contact.delivery_address = delivery_address
     contact.save()
     customer = Customer()
     customer.contact = contact
     customer.save()