Advertisement
lukio

wizard-campo-one2many

Jul 2nd, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.81 KB | None | 0 0
  1. class CalculoPapelStart(ModelView):
  2.     'Modelo Wizard Calculo Papel'
  3.     _name = 'sale_imprenta.calculo.papel.start'
  4.  
  5.     producto_papel = fields.One2Many('product.template','products' ,u'Papel',
  6.                         domain=[('category', '=', Id('sale_imprenta', 'cat_papel'))],
  7.                         required=True, readonly=False,
  8.                         )
  9. CalculoPapelStart()
  10.  
  11.  
  12. class CalculoPapel(Wizard):
  13.     'Wizard Calcular Papel'
  14.     _name = 'sale_imprenta.calculo.papel'
  15.  
  16.     start = StateView('sale_imprenta.calculo.papel.start',
  17.     'sale_imprenta.calculo_papel_start_view_form', [
  18.     Button('Cancelar', 'end', 'tryton-cancel'),
  19.     Button('Siguiente', 'buscar_papel', 'tryton-go-next', True),
  20.     ])
  21.  
  22.     buscar_papel = StateTransition()
  23.  
  24.     seleccion = StateView('sale_imprenta.calculo.papel.start',
  25.     'sale_imprenta.calculo_papel_seleccion_view_form', [
  26.     Button('Cancelar', 'end', 'tryton-cancel'),
  27.     Button('Atras', 'volver_start', 'tryton-go-previous'),
  28.     Button('Finalizar', 'terminar', 'tryton-ok', True),
  29.     ])
  30.  
  31.     volver_start = StateTransition()
  32.  
  33.     def transition_buscar_papel(self, session):
  34.         return 'seleccion'
  35.  
  36.     def default_seleccion(self, session, fields):
  37.         pool = Pool()
  38.         product_obj = pool.get('product.template')
  39.         line_obj = pool.get('sale.line')
  40.         product = product_obj.search([])
  41.         pro = product_obj.browse(product)[0]
  42.  
  43.         res = {
  44.             'producto_papel': {},
  45.         }
  46.        
  47.         ## TODO: I want to relate some products to my One2Many field producto_papel
  48.         res['producto_papel'].setdefault('add', [product])
  49.         return res
  50.  
  51.     def transition_volver_start(self, session):
  52.         return 'start'
  53.  
  54.     def transition_terminar(self, session):
  55.         return 'end'
  56.  
  57. CalculoPapel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement