Exemplo n.º 1
0
    def save(self):
        client = get_object_or_404(Client,
                                   id=self.cleaned_data.get('clientId'))
        manager = get_object_or_404(User,
                                    username=self.cleaned_data.get('manager'))
        user = get_object_or_404(User,
                                 username=self.cleaned_data.get('author'))
        contactPerson = get_object_or_404(
            Persons, id=self.cleaned_data.get('contactPersonId'))

        order = Order(
            client=client,
            status=self.cleaned_data.get('status'),
            call_on=self.cleaned_data.get('call_on'),
            call_or_email=self.cleaned_data.get('call_or_email'),
            contactPerson=contactPerson,
            manager=manager,
            author=user,
        )
        order.save()

        #create order_process
        order_process = Order_process(
            order=order,
            step=1,
            step_description=self.cleaned_data.get('step_description'),
            manager=manager,
        )
        order_process.save()

        return order
Exemplo n.º 2
0
    def save(self, **kwargs):
        user = get_object_or_404(User,
                                 username=self.cleaned_data.get('author'))
        client = Client(author=user)
        client.save()

        person = Persons(
            client=client,
            firstName=self.cleaned_data.get('firstName'),
            telephoneNum1=self.cleaned_data.get('telephoneNum1'),
            email1=self.cleaned_data.get('email1'),
            author=user,
        )
        person.save()

        manager = get_object_or_404(User,
                                    username=self.cleaned_data.get('manager'))

        order = Order(
            client=client,
            status=self.cleaned_data.get('status'),
            call_on=self.cleaned_data.get('call_on'),
            call_or_email=self.cleaned_data.get('call_or_email'),
            manager=manager,
            contactPerson=person,
            author=user,
        )
        order.save()

        #create order_process
        order_process = Order_process(
            order=order,
            step=1,
            step_description=self.cleaned_data.get('step_description'),
            manager=manager,
        )
        order_process.save()

        if self.cleaned_data.get('city'):
            legal_details = Legal_details(
                client=client,
                city=self.cleaned_data.get('city'),
                author=user,
            )
            legal_details.save()

        return client