Esempio n. 1
0
    def post(self, request, *args, **kwargs):
        self.object = self.get_object()
        form_class = self.get_form_class()

        # Remover separados de milhar .
        req_post = request.POST.copy()
        req_post['v_orig'] = req_post['v_orig'].replace('.', '')
        req_post['v_desc'] = req_post['v_desc'].replace('.', '')
        req_post['v_liq'] = req_post['v_liq'].replace('.', '')
        request.POST = req_post

        form = form_class(request.POST, request.FILES, instance=self.object)
        aut_form = AutXMLFormSet(request.POST,
                                 prefix='aut_form',
                                 instance=self.object)

        if (form.is_valid() and aut_form.is_valid()):
            self.object = form.save(commit=False)
            self.object.status_nfe = u'3'
            self.atualizar_campos(request.POST)
            self.object.save()

            return self.form_valid(form)

        return self.form_invalid(form=form, aut_form=aut_form)
Esempio n. 2
0
    def post(self, request, form_class, *args, **kwargs):
        self.object = None

        # Remover separados de milhar .
        req_post = request.POST.copy()
        for key in req_post:
            if ('v_' in key):
                req_post[key] = req_post[key].replace('.', '')
        request.POST = req_post

        form = self.get_form(form_class)
        aut_form = AutXMLFormSet(request.POST, prefix='aut_form')

        if (form.is_valid() and aut_form.is_valid()):
            self.object = form.save(commit=False)
            if isinstance(self.object, NotaFiscalSaida):
                self.atualizar_campos(request.POST)
            self.object.save()

            return self.form_valid(form)

        return self.form_invalid(form=form, aut_form=aut_form)