Advertisement
lukio

tryton add button presupuesto.py

May 24th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1. from trytond.model import Workflow, ModelView, ModelSQL, fields
  2. from trytond.wizard import Wizard, StateView, StateTransition, Button
  3. from trytond.transaction import Transaction
  4. from trytond.pool import Pool
  5.  
  6. class Presupuesto(ModelSQL, ModelView):
  7.     'Presupuesto'
  8.     _name = 'presupuesto.presupuesto'
  9.     _description = __doc__
  10.     name = fields.Char('Name')
  11.     greeting = fields.Char('Greeting')
  12.     edad = fields.Char('Edad')
  13.     state = fields.Selection([
  14.         ('draft', 'Draft'),
  15.         ('quotation', 'Quotation'),
  16.         ('confirmed', 'Confirmed'),
  17.         ('processing', 'Processing'),
  18.         ('done', 'Done'),
  19.         ('cancel', 'Canceled'),
  20.     ], 'State', readonly=False, required=False)
  21.     def __init__(self):
  22.         super(Presupuesto, self).__init__()
  23.  
  24.         self._buttons.update({
  25.                 'cancel': {
  26.                     'invisible': ((Eval('state') == 'cancel')
  27.                         | (~Eval('state').in_(['draft', 'quotation'])
  28.                             & (Eval('invoice_state') != 'exception')
  29.                             & (Eval('shipment_state') != 'exception'))),
  30.                     },
  31.                 'draft': {
  32.                     'invisible': Eval('state') != 'quotation',
  33.                     },
  34.                 'quote': {
  35.                     'invisible': Eval('state') != 'draft',
  36.                     'readonly': ~Eval('lines', []),
  37.                     },
  38.                 'confirm': {
  39.                     'invisible': Eval('state') != 'quotation',
  40.                     },
  41.                 'process': {
  42.                     'invisible': Eval('state') != 'confirmed',
  43.                     },
  44.                 })
  45.         # The states where amounts are cached
  46.         self._states_cached = ['confirmed', 'processing', 'done', 'cancel']
  47.  
  48.     @ModelView.button
  49.     @Workflow.transition('cancel')
  50.     def cancel(self, ids):
  51.         import pdb; pdb.set_trace()
  52.         self.store_cache(ids)
  53.  
  54. Presupuesto()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement