Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @login_required(login_url='/login/')
- def EditaPedido(request, pedido_id=None):
- profile = request.user.get_profile()
- if pedido_id:
- vPedido = Pedido.objects.using(profile.dbname).get(idpedido=pedido_id)
- else:
- vPedido = None
- ItensInlineFormSet = inlineformset_factory(Pedido, ItensPedido, form=PedidoItensForm,
- extra=1, fk_name='idpedido')
- if request.method == "POST":
- formPedido = PedidoForm(request.POST, vUserProfile=profile)
- else:
- formPedido = PedidoForm(vUserProfile=profile, instance=vPedido)
- formsetItens = ItensInlineFormSet(instance=vPedido)
- vMercadoria = Mercadoria.objects.using(profile.dbname).filter(status='A')
- # .filter(idsys_point_cliente=profile.idsys_point_cliente)\
- # .filter(idempresa=profile.idempresa)\
- vProduto = Produto.objects.using(profile.dbname).all()
- # vitens = ItensPedido.objects.using(profile.dbname).filter(idpedido=pedido_id).select_related()
- return render_to_response("edit_pedido.html", {
- "formPedido": formPedido, "formsetItens": formsetItens,
- "vMercadoria": vMercadoria, "vProduto": vProduto
- }, context_instance=RequestContext(request), )
- HTML:
- <fieldset>
- <legend>Itens do pedido</legend>
- <a href="#" class="tiny button" onclick="abreModal()">Novo Item</a>
- <table id="grid_itens" class="dataTable">
- <thead>
- <tr>
- <th>Referência</th>
- <th>Produto</th>
- <th>Cor</th>
- <th>Qtde</th>
- <th>Preço Unit.</th>
- <th>Preço Total</th>
- <th>Excluir</th>
- </tr>
- </thead>
- <tbody>
- {% for itens in formsetItens.forms %}
- <tr>
- <td> </td>
- <td>{{ itens.idproduto.value }}</td>
- <td>{{ itens.idproduto__idcor__descricao.value }}</td>
- <td>{{ itens.quantidade.value }}</td>
- <td>xxxx</td>
- <td>xxxxx</td>
- <td>Excluir</td>
- </tr>
- {% endfor %}
- </tbody>
- <tfoot>
- <tr>
- <th></th>
- <th></th>
- <th></th>
- <th>9999</th>
- <th></th>
- <th>9999,00</th>
- <th></th>
- </tr>
- </tfoot>
- </table>
- </fieldset>
- {{ formsetItens.management_form }}
Advertisement
Add Comment
Please, Sign In to add comment