- 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: