removed bad code
[odoo/odoo.git] / bin / addons / base / ir / ir_sequence.py
index 71675f5..f48ea0f 100644 (file)
@@ -22,7 +22,6 @@
 
 import time
 from osv import fields,osv
-from tools.safe_eval import safe_eval
 import pooler
 
 class ir_sequence_type(osv.osv):
@@ -48,15 +47,12 @@ class ir_sequence(osv.osv):
         'number_next': fields.integer('Next Number', required=True),
         'number_increment': fields.integer('Increment Number', required=True),
         'padding' : fields.integer('Number padding', required=True),
-       'condition': fields.char('Condition', size=250, help="If set, sequence will only be used in case this python expression matches, and will precede other sequences."),
-       'weight': fields.integer('Weight',required=True, help="If two sequences match, the highest weight will be used.")
     }
     _defaults = {
         'active': lambda *a: True,
         'number_increment': lambda *a: 1,
         'number_next': lambda *a: 1,
         'padding' : lambda *a : 0,
-       'weight' : lambda *a: 10,
     }
 
     def _process(self, s):
@@ -75,29 +71,10 @@ class ir_sequence(osv.osv):
         }
 
     def get_id(self, cr, uid, sequence_id, test='id=%s', context=None):
-       if not context:
-               context = {}
         try:
-            cr.execute('SELECT id, number_next, prefix, suffix, padding, condition \
-               FROM ir_sequence \
-               WHERE '+test+' AND active=%s ORDER BY weight DESC, length(COALESCE(condition,\'\')) DESC \
-               FOR UPDATE', (sequence_id, True))
-            for res in cr.dictfetchall():
-               if res['condition']:
-                       print "ir_seq: %s has condition:" %res['id'], res['condition'], 
-                       try:
-                           bo = safe_eval(res['condition'],context)
-                           if not bo:
-                               print "not matched"
-                               continue
-                       except Exception,e:
-                               # it would be normal to have exceptions, because
-                               # the domain may contain errors
-                               print "Exception.\ne:",e
-                               print "Context:", context
-                               continue
-                       print "Matched!"
-
+            cr.execute('SELECT id, number_next, prefix, suffix, padding FROM ir_sequence WHERE '+test+' AND active=%s FOR UPDATE', (sequence_id, True))
+            res = cr.dictfetchone()
+            if res:
                 cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=%s', (res['id'], True))
                 if res['number_next']:
                     return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
@@ -107,8 +84,8 @@ class ir_sequence(osv.osv):
             cr.commit()
         return False
 
-    def get(self, cr, uid, code, context = None):
-        return self.get_id(cr, uid, code, test='code=%s',context=context)
+    def get(self, cr, uid, code):
+        return self.get_id(cr, uid, code, test='code=%s')
 ir_sequence()