Advertisement
lukio

problem-sale-active-ids-wizard

Jun 25th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. class ImprentaConfirmarStart(ModelSQL, ModelView):
  2.     'Modelo Confirmar Venta'
  3.     _name = 'sale_imprenta.confirmar.start'
  4.  
  5.     cantidad_confirmada = fields.Selection('obtener_cantidades'
  6.         , 'Cantidad confirmada')
  7.  
  8.     def obtener_cantidades(self):
  9.         import pdb; pdb.set_trace()
  10.         # I would like to have active_ids so i can get the value of my sale to create the selection field.                                                                                                  # not working ..                              
  11.         ventas_obj = Pool().get('sale.sale').browse(Transaction().context.get('active_ids'))
  12.  
  13.         # EXAMPLE of return
  14.         return [ ('100', '100'), ('200', '200') ]
  15.  
  16. ImprentaConfirmarStart()
  17.  
  18. class ImprentaConfirmarSale(Wizard):
  19.     'Wizard Confirmar Venta. Confirma la cantidad de venta'
  20.     _name = 'sale_imprenta.confirmar'
  21.  
  22.     start = StateView('sale_imprenta.confirmar.start',
  23.     'sale_imprenta.cantidad_confirmar_form', [
  24.     Button('Cancelar', 'end', 'tryton-cancel'),
  25.     Button('Aceptar', 'aceptar', 'tryton-ok', True),
  26.     ])
  27.  
  28.     aceptar = StateTransition()
  29.  
  30.     def transition_aceptar(self, session):
  31.         print "Transition Acepto Confirmacion"
  32.         ventas_obj = Pool().get('sale.sale').browse(Transaction().context.get('active_ids'))
  33.  
  34.         for venta in ventas_obj:
  35.             venta.write(venta.id, {'state':'confirmed'})
  36.  
  37.         return 'end'
  38.  
  39. ImprentaConfirmarSale()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement