Advertisement
lukio

domain-fields

Jul 5th, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.72 KB | None | 0 0
  1. class CalculoPapelProducto(ModelSQL, ModelView):
  2.     'Modelo Wizard Calculo Papel'
  3.     _name = 'sale_imprenta.producto'
  4.  
  5.     #Campos definidos en modelo product.template
  6.     orientacion = fields.Selection([
  7.             ('H', 'Horizontal'),
  8.             ('V', 'Vertical'),
  9.             ], u'Orientación')
  10.     cantidad_hojas_necesarias = fields.Integer('Cantidad de Hojas')
  11.     desperdicio = fields.Numeric('Desperdicio', digits=(3, 2))
  12.     paginas_por_hoja = fields.Integer('Paginas por Hoja')
  13.     name = fields.Char('Name', size=None, translate=True,
  14.         select=True)
  15.     producto = fields.Many2One('product.template', 'Producto',
  16.             select=True)
  17.     height = fields.Float('Height', digits=(16, 2))
  18.     width = fields.Float('Width', digits=(16, 2))
  19.     id_wizard = fields.Integer('id del wizard')
  20.  
  21. CalculoPapelProducto()
  22.  
  23.  
  24. class CalculoPapelStart(ModelView):
  25.     'Modelo Wizard Calculo Papel'
  26.     _name = 'sale_imprenta.calculo.papel.start'
  27.  
  28.     producto_papel = fields.Many2One('sale_imprenta.producto',u'Papel',
  29.                         domain=[('id_wizard', '=', Get(Eval('context', {}), 'active_id', '0'))],
  30.                         required=False
  31.                         )
  32.    #######
  33.    ## The domain it's not working :(
  34. CalculoPapelStart()
  35.  
  36. class CalculoPapel(Wizard):
  37.     'Wizard Calcular Papel'
  38.     _name = 'sale_imprenta.calculo.papel'
  39.  
  40.     start = StateView('sale_imprenta.calculo.papel.start',
  41.     'sale_imprenta.calculo_papel_start_view_form', [
  42.     Button('Cancelar', 'end', 'tryton-cancel'),
  43.     Button('Siguiente', 'buscar_papel', 'tryton-go-next', True),
  44.     ])
  45.  
  46.     buscar_papel = StateTransition()
  47.  
  48.     seleccion = StateView('sale_imprenta.calculo.papel.start',
  49.     'sale_imprenta.calculo_papel_seleccion_view_form', [
  50.     Button('Cancelar', 'end', 'tryton-cancel'),
  51.     Button('Atras', 'volver_start', 'tryton-go-previous'),
  52.     Button('Finalizar', 'terminar', 'tryton-ok', True),
  53.     ])
  54.  
  55.     volver_start = StateTransition()
  56.     terminar = StateTransition()
  57.  
  58.     def transition_buscar_papel(self, session):
  59.         return 'seleccion'
  60.  
  61.     def default_seleccion(self, session, fields):
  62.         res = {}
  63.         pool = Pool()
  64.         wiz_obj = pool.get('sale_imprenta.calculo.papel.start')
  65.  
  66.         t = Transaction()
  67.         id_wizard = t.context.get('active_id')
  68.  
  69.         producto_wiz_obj = pool.get('sale_imprenta.producto')
  70.         producto_wiz_obj.create({'name':'Basura '+ str(id_wizard), 'id_wizard': id_wizard})
  71.  
  72.         return res
  73.  
  74.     def default_start(self, session, fields):
  75.         return session.data['start']
  76.  
  77.     def transition_volver_start(self, session):
  78.         return 'start'
  79.  
  80.     def transition_terminar(self, session):
  81.         return 'end'
  82.  
  83. CalculoPapel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement