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)
def get(self, request, *args, **kwargs): self.object = self.get_object() form_class = self.get_form_class() form = self.get_form(form_class) aut_form = AutXMLFormSet(instance=self.object, prefix='aut_form') if AutXML.objects.filter(nfe=self.object.pk).count(): aut_form.extra = 0 errors_validacao = ErrosValidacaoNotaFiscal.objects.filter( nfe=self.object) resposta_sefaz = RespostaSefazNotaFiscal.objects.filter( nfe=self.object) return self.render_to_response(self.get_context_data(form=form, aut_form=aut_form, errors_validacao=errors_validacao, resposta_sefaz=resposta_sefaz,))
def get(self, request, form_class, *args, **kwargs): self.object = None form = self.get_form(form_class) form = self.set_form_initial_data(form, request.user) aut_form = AutXMLFormSet(prefix='aut_form') return self.render_to_response(self.get_context_data(form=form, aut_form=aut_form,))
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)