Bugfixes and improvements
[odoo/odoo.git] / bin / osv / fields.py
1 # -*- encoding: iso-8859-1 -*-
2 ##############################################################################
3 #
4 # Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 #
6 # $Id$
7 #
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
13 # Service Company
14 #
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28 #
29 ##############################################################################
30
31 # . Fields:
32 #      - simple
33 #      - relations (one2many, many2one, many2many)
34 #      - function
35 #
36 # Fields Attributes:
37 #   _classic_read: is a classic sql fields
38 #   _type   : field type
39 #   readonly
40 #   required
41 #   size
42 #
43 import string
44 import netsvc
45
46 import psycopg
47 import warnings
48
49 import tools
50
51 def _symbol_set(symb):
52         if symb==None or symb==False:
53                 return None
54         elif isinstance(symb, unicode):
55                 return symb.encode('utf-8')
56         return str(symb)
57
58 class _column(object):
59         _classic_read = True
60         _classic_write = True
61         _properties = False
62         _type = 'unknown'
63         _obj = None
64         _symbol_c = '%s'
65         _symbol_f = _symbol_set
66         _symbol_set = (_symbol_c, _symbol_f)
67         _symbol_get = None
68
69         def __init__(self, string='unknown', required=False, readonly=False, domain=None, context='', states=None, priority=0, change_default=False, size=None, ondelete="set null", translate=False, select=False, **args):
70                 self.states = states or {}
71                 self.string = string
72                 self.readonly = readonly
73                 self.required = required
74                 self.size = size
75                 self.help = args.get('help', '')
76                 self.priority = priority
77                 self.change_default = change_default
78                 self.ondelete = ondelete
79                 self.translate = translate
80                 self._domain = domain or []
81                 self.relate =False
82                 self._context = context
83                 self.group_name = False
84                 self.view_load = 0
85                 self.select=select
86                 for a in args:
87                         if args[a]:
88                                 setattr(self, a, args[a])
89                 if self.relate:
90                         warnings.warn("The relate attribute doesn't work anymore, use act_window tag instead", DeprecationWarning)
91
92         def restart(self):
93                 pass
94
95         def set(self, cr, obj, id, name, value, user=None, context=None):
96                 cr.execute('update '+obj._table+' set '+name+'='+self._symbol_set[0]+' where id=%d', (self._symbol_set[1](value),id) )
97
98         def get(self, cr, obj, ids, name, context=None, values=None):
99                 raise Exception, 'undefined get method !'
100
101         def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None):
102                 ids = obj.search(cr, uid, args+self._domain+[(name,'ilike',value)], offset, limit)
103                 res = obj.read(cr, uid, ids, [name])
104                 return [x[name] for x in res]
105
106 # ---------------------------------------------------------
107 # Simple fields
108 # ---------------------------------------------------------
109 class boolean(_column):
110         _type = 'boolean'
111         _symbol_c = '%s'
112         _symbol_f = lambda x: x and 'True' or 'False'
113         _symbol_set = (_symbol_c, _symbol_f)
114
115 class integer(_column):
116         _type = 'integer'
117         _symbol_c = '%d'
118         _symbol_f = lambda x: int(x or 0)
119         _symbol_set = (_symbol_c, _symbol_f)
120
121 class reference(_column):
122         _type = 'reference'
123         def __init__(self, string, selection, size, **args):
124                 _column.__init__(self, string=string, size=size, selection=selection, **args)
125
126 class char(_column):
127         _type = 'char'
128         
129         def __init__(self, string, size, **args):
130                 _column.__init__(self, string=string, size=size, **args)
131                 self._symbol_set = (self._symbol_c, self._symbol_set_char)
132                 
133         # takes a string (encoded in utf8) and returns a string (encoded in utf8)
134         def _symbol_set_char(self, symb):
135                 #TODO: 
136                 # * we need to remove the "symb==False" from the next line BUT 
137                 #   for now too many things rely on this broken behavior
138                 # * the symb==None test should be common to all data types
139                 if symb==None or symb==False:
140                         return None
141
142                 # we need to convert the string to a unicode object to be able 
143                 # to evaluate its length (and possibly truncate it) reliably
144                 if isinstance(symb, str):
145                         u_symb = unicode(symb, 'utf8')
146                 elif isinstance(symb, unicode):
147                         u_symb = symb
148                 else:
149                         u_symb = unicode(symb)
150                         
151                 if len(u_symb) > self.size:
152                         return u_symb[:self.size-3].encode('utf8') + '...'
153                 else:
154                         return u_symb.encode('utf8')
155
156 class text(_column):
157         _type = 'text'
158
159 import __builtin__
160
161 class float(_column):
162         _type = 'float'
163         _symbol_c = '%f'
164         _symbol_f = lambda x: __builtin__.float(x or 0.0)
165         _symbol_set = (_symbol_c, _symbol_f)
166         def __init__(self, string='unknown', digits=None, **args):
167                 _column.__init__(self, string=string, **args)
168                 self.digits = digits
169
170 # We'll need to use decimal one day or another
171 #try:
172 #       import decimal
173 #except ImportError:
174 #       from tools import decimal
175 #
176 #class float(_column):
177 #       _type = 'float'
178 #       _symbol_c = '%f'
179 #       def __init__(self, string='unknown', digits=None, **args):
180 #               _column.__init__(self, string=string, **args)
181 #               self._symbol_set = (self._symbol_c, self._symbol_set_decimal)
182 #               self.digits = digits
183 #               if not digits:
184 #                       scale = 4
185 #               else:
186 #                       scale = digits[1]
187 #               self._scale = decimal.Decimal(str(10**-scale))
188 #               self._context = decimal.Context(prec=scale, rounding=decimal.ROUND_HALF_UP)
189 #
190 #       def _symbol_set_decimal(self, symb):
191 #               if isinstance(symb, __builtin__.float):
192 #                       return decimal.Decimal('%f' % symb)
193 #               return decimal.Decimal(symb)
194
195 class date(_column):
196         _type = 'date'
197
198 class datetime(_column):
199         _type = 'datetime'
200
201 class time(_column):
202         _type = 'time'
203
204 class binary(_column):
205         _type = 'binary'
206         _symbol_c = '%s'
207         _symbol_f = lambda symb: symb and psycopg.Binary(symb) or None
208         _symbol_set = (_symbol_c, _symbol_f)
209
210 class selection(_column):
211         _type = 'selection'
212         
213         def __init__(self, selection, string='unknown', **args):
214                 _column.__init__(self, string=string, **args)
215                 self.selection = selection
216
217         def set(self, cr, obj, id, name, value, user=None, context=None):
218                 if not context:
219                         context={}
220 #CHECKME: a priori, ceci n'est jamais appelé puisque le test ci-dessous est mauvais
221 # la raison est que selection n'est pas en classic_write = false
222 # a noter qu'on pourrait fournir un _symbol_set specifique, et ca suffirait
223                 if value in self.selection:
224                         raise Exception, 'BAD VALUE'
225                 _column.set(self, cr, obj, id, name, value, user=None, context=context)
226
227
228 # ---------------------------------------------------------
229 # Relationals fields
230 # ---------------------------------------------------------
231
232 #
233 # Values: (0, 0,  { fields })    create
234 #         (1, ID, { fields })    modification
235 #         (2, ID)                remove (delete)
236 #         (3, ID)                unlink one (target id or target of relation)
237 #         (4, ID)                link
238 #         (5)                    unlink all (only valid for one2many)
239 #
240 #CHECKME: dans la pratique c'est quoi la syntaxe utilisee pour le 5? (5) ou (5, 0)?
241 class one2one(_column):
242         _classic_read = False
243         _classic_write = True
244         _type = 'one2one'
245         
246         def __init__(self, obj, string='unknown', **args):
247                 warnings.warn("The one2one field doesn't work anymore", DeprecationWarning)
248                 _column.__init__(self, string=string, **args)
249                 self._obj = obj
250
251         def set(self, cr, obj_src, id, field, act, user=None, context=None):
252                 if not context:
253                         context={}
254                 obj = obj_src.pool.get(self._obj)
255                 self._table = obj_src.pool.get(self._obj)._table
256                 if act[0]==0:
257                         id_new = obj.create(cr, user, act[1])
258                         cr.execute('update '+obj_src._table+' set '+field+'=%d where id=%d', (id_new,id))
259                 else:
260                         cr.execute('select '+field+' from '+obj_src._table+' where id=%d', (act[0],))
261                         id =cr.fetchone()[0]
262                         obj.write(cr, user, [id] , act[1], context=context)
263
264         def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None):
265                 return obj.pool.get(self._obj).search(cr, uid, args+self._domain+[('name','like',value)], offset, limit)
266
267
268 class many2one(_column):
269         _classic_read = False
270         _classic_write = True
271         _type = 'many2one'
272         
273         def __init__(self, obj, string='unknown', **args):
274                 _column.__init__(self, string=string, **args)
275                 self._obj = obj
276
277         #
278         # TODO: speed improvement
279         #
280         # name is the name of the relation field
281         def get(self, cr, obj, ids, name, user=None, context=None, values=None):
282                 if not context:
283                         context={}
284                 if not values:
285                         values={}
286                 res = {}
287                 for r in values:
288                         res[r['id']] = r[name]
289                 for id in ids:
290                         res.setdefault(id, '')
291                 obj = obj.pool.get(self._obj)
292                 # build a dictionary of the form {'id_of_distant_resource': name_of_distant_resource}
293                 from orm import except_orm
294                 try:
295                         names = dict(obj.name_get(cr, user, filter(None, res.values()), context))
296                 except except_orm:
297                         names={}
298
299                         iids = filter(None, res.values())
300                         cr.execute('select id,'+obj._rec_name+' from '+obj._table+' where id in ('+','.join(map(str,iids))+')')
301                         for res22 in cr.fetchall():
302                                 names[res22[0]] = res22[1]
303
304                 for r in res.keys():
305                         if res[r] and res[r] in names:
306                                 res[r] = (res[r], names[res[r]])
307                         else:
308                                 res[r] = False
309                 return res
310
311         def set(self, cr, obj_src, id, field, values, user=None, context=None):
312                 if not context:
313                         context={}
314                 obj = obj_src.pool.get(self._obj)
315                 self._table = obj_src.pool.get(self._obj)._table
316                 if type(values)==type([]):
317                         for act in values:
318                                 if act[0]==0:
319                                         id_new = obj.create(cr, act[2])
320                                         cr.execute('update '+obj_src._table+' set '+field+'=%d where id=%d', (id_new,id))
321                                 elif act[0]==1:
322                                         obj.write(cr, [act[1]], act[2], context=context)
323                                 elif act[0]==2:
324                                         cr.execute('delete from '+self._table+' where id=%d', (act[1],))
325                                 elif act[0]==3 or act[0]==5:
326                                         cr.execute('update '+obj_src._table+' set '+field+'=null where id=%d', (id,))
327                                 elif act[0]==4:
328                                         cr.execute('update '+obj_src._table+' set '+field+'=%d where id=%d', (act[1],id))
329                 else:
330                         if values:
331                                 cr.execute('update '+obj_src._table+' set '+field+'=%d where id=%d', (values,id))
332                         else:
333                                 cr.execute('update '+obj_src._table+' set '+field+'=null where id=%d', (id,))
334
335         def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None):
336                 return obj.pool.get(self._obj).search(cr, uid, args+self._domain+[('name','like',value)], offset, limit)
337
338 class one2many(_column):
339         _classic_read = False
340         _classic_write = False
341         _type = 'one2many'
342         
343         def __init__(self, obj, fields_id, string='unknown', limit=None, **args):
344                 _column.__init__(self, string=string, **args)
345                 self._obj = obj
346                 self._fields_id = fields_id
347                 self._limit = limit
348                 #one2many can't be used as condition for defaults
349                 assert(self.change_default != True)
350         
351         def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
352                 if not context:
353                         context = {}
354                 if not values:
355                         values = {}
356                 res = {}
357                 for id in ids:
358                         res[id] = []
359                 ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids)], limit=self._limit)
360                 for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
361                         res[r[self._fields_id]].append( r['id'] )
362                 return res
363
364         def set(self, cr, obj, id, field, values, user=None, context=None):
365                 if not context:
366                         context={}
367                 if not values:
368                         return
369                 _table = obj.pool.get(self._obj)._table
370                 obj = obj.pool.get(self._obj)
371                 for act in values:
372                         if act[0]==0:
373                                 act[2][self._fields_id] = id
374                                 obj.create(cr, user, act[2], context=context)
375                         elif act[0]==1:
376                                 obj.write(cr, user, [act[1]] , act[2], context=context)
377                         elif act[0]==2:
378                                 obj.unlink(cr, user, [act[1]], context=context)
379                         elif act[0]==3:
380                                 cr.execute('update '+_table+' set '+self._fields_id+'=null where id=%d', (act[1],))
381                         elif act[0]==4:
382                                 cr.execute('update '+_table+' set '+self._fields_id+'=%d where id=%d', (id,act[1]))
383                         elif act[0]==5:
384                                 cr.execute('update '+_table+' set '+self._fields_id+'=null where '+self._fields_id+'=%d', (id,))
385                         elif act[0]==6:
386                                 if not act[2]:
387                                         ids2 = [0]
388                                 else:
389                                         ids2 = act[2]
390                                 cr.execute('update '+_table+' set '+self._fields_id+'=NULL where '+self._fields_id+'=%d and id not in ('+','.join(map(str, ids2))+')', (id,))
391                                 if act[2]:
392                                         cr.execute('update '+_table+' set '+self._fields_id+'=%d where id in ('+','.join(map(str, act[2]))+')', (id,))
393         def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, operator='like'):
394                 return obj.pool.get(self._obj).name_search(cr, uid, value, self._domain, offset, limit)
395
396 #
397 # Values: (0, 0,  { fields })    create
398 #         (1, ID, { fields })    modification
399 #         (2, ID)                remove
400 #         (3, ID)                unlink
401 #         (4, ID)                link
402 #         (5, ID)                unlink all
403 #         (6, ?, ids)            set a list of links
404 #
405 class many2many(_column):
406         _classic_read = False
407         _classic_write = False
408         _type = 'many2many'
409         
410         def __init__(self, obj, rel, id1, id2, string='unknown', limit=None, **args):
411                 _column.__init__(self, string=string, **args)
412                 self._obj = obj
413                 self._rel = rel
414                 self._id1 = id1
415                 self._id2 = id2
416                 self._limit = limit
417
418         def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
419                 if not context:
420                         context={}
421                 if not values:
422                         values={}
423                 res = {}
424                 if not ids:
425                         return res
426                 for id in ids:
427                         res[id] = []
428                 ids_s = ','.join(map(str,ids))
429                 limit_str = self._limit is not None and ' limit %d' % self._limit or ''
430                 obj = obj.pool.get(self._obj)
431
432                 d1, d2 = obj.pool.get('ir.rule').domain_get(cr, user, obj._name)
433                 if d1:
434                         d1 = ' and '+d1
435
436                 cr.execute('SELECT '+self._rel+'.'+self._id2+','+self._rel+'.'+self._id1+' \
437                                 FROM '+self._rel+' , '+obj._table+' \
438                                 WHERE '+self._rel+'.'+self._id1+' in ('+ids_s+') \
439                                         AND '+self._rel+'.'+self._id2+' = '+obj._table+'.id '+d1
440                                 +limit_str+' order by '+obj._table+'.'+obj._order+' offset %d',
441                                 d2+[offset])
442                 for r in cr.fetchall():
443                         res[r[1]].append(r[0])
444                 return res
445
446         def set(self, cr, obj, id, name, values, user=None, context=None):
447                 if not context:
448                         context={}
449                 if not values:
450                         return
451                 obj = obj.pool.get(self._obj)
452                 for act in values:
453                         if act[0]==0:
454                                 idnew = obj.create(cr, user, act[2])
455                                 cr.execute('insert into '+self._rel+' ('+self._id1+','+self._id2+') values (%d,%d)', (id,idnew))
456                         elif act[0]==1:
457                                 obj.write(cr, user, [act[1]] , act[2], context=context)
458                         elif act[0]==2:
459                                 obj.unlink(cr, user, [act[1]], context=context)
460                         elif act[0]==3:
461                                 cr.execute('delete from '+self._rel+' where ' +  self._id1 + '=%d and '+ self._id2 + '=%d', (id,act[1]))
462                         elif act[0]==4:
463                                 cr.execute('insert into '+self._rel+' ('+self._id1+','+self._id2+') values (%d,%d)', (id,act[1]))
464                         elif act[0]==5:
465                                 cr.execute('update '+self._rel+' set '+self._id2+'=null where '+self._id2+'=%d', (id,))
466                         elif act[0]==6:
467
468                                 d1, d2 = obj.pool.get('ir.rule').domain_get(cr, user, obj._name) 
469                                 if d1:
470                                         d1 = ' and '+d1
471                                 cr.execute('delete from '+self._rel+' where '+self._id1+'=%d AND '+self._id2+' IN (SELECT '+self._rel+'.'+self._id2+' FROM '+self._rel+', '+obj._table+' WHERE '+self._rel+'.'+self._id1+'=%d AND '+self._rel+'.'+self._id2+' = '+obj._table+'.id '+ d1 +')', [id, id]+d2 )
472
473                                 for act_nbr in act[2]: 
474                                         cr.execute('insert into '+self._rel+' ('+self._id1+','+self._id2+') values (%d, %d)', (id, act_nbr))
475
476         #
477         # TODO: use a name_search
478         #
479         def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, operator='like'):
480                 return obj.pool.get(self._obj).search(cr, uid, args+self._domain+[('name',operator,value)], offset, limit)
481
482 # ---------------------------------------------------------
483 # Function fields
484 # ---------------------------------------------------------
485
486 class function(_column):
487         _classic_read = False
488         _classic_write = False
489         _type = 'function'
490         _properties = True
491         
492         def __init__(self, fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type='float', fnct_search=None, obj=None, method=False, store=False, **args):
493                 _column.__init__(self, **args)
494                 self._obj = obj
495                 self._method = method
496                 self._fnct = fnct
497                 self._fnct_inv = fnct_inv
498                 self._arg = arg
499                 if 'relation' in args:
500                         self._obj = args['relation']
501                 self._fnct_inv_arg = fnct_inv_arg
502                 if not fnct_inv:
503                         self.readonly = 1
504                 self._type = type
505                 self._fnct_search = fnct_search
506                 self.store = store
507                 if type == 'float':
508                         self._symbol_c = '%f'
509                         self._symbol_f = lambda x: __builtin__.float(x or 0.0)
510                         self._symbol_set = (self._symbol_c, self._symbol_f)
511                 
512         def search(self, cr, uid, obj, name, args):
513                 if not self._fnct_search:
514                         #CHECKME: should raise an exception
515                         return []
516                 return self._fnct_search(obj, cr, uid, obj, name, args)
517
518         def get(self, cr, obj, ids, name, user=None, context=None, values=None):
519                 if not context:
520                         context={}
521                 if not values:
522                         values={}
523                 res = {}
524                 table = obj._table
525                 if self._method:
526                         # TODO get HAS to receive uid for permissions !
527                         return self._fnct(obj, cr, user, ids, name, self._arg, context)
528                 else:
529                         return self._fnct(cr, table, ids, name, self._arg, context)
530
531         def set(self, cr, obj, id, name, value, user=None, context=None):
532                 if not context:
533                         context={}
534                 if self._fnct_inv:
535                         self._fnct_inv(obj, cr, user, id, name, value, self._fnct_inv_arg, context)
536
537 # ---------------------------------------------------------
538 # Serialized fields
539 # ---------------------------------------------------------
540 class serialized(_column):
541         def __init__(self, string='unknown', serialize_func=repr, deserialize_func=eval, type='text', **args):
542                 self._serialize_func = serialize_func
543                 self._deserialize_func = deserialize_func
544                 self._type = type
545                 self._symbol_set = (self._symbol_c, self._serialize_func)
546                 self._symbol_get = self._deserialize_func
547                 super(serialized, self).__init__(string=string, **args)
548
549
550 class property(function):
551
552         def _fnct_write(self, obj, cr, uid, id, prop, id_val, val, context=None):
553                 if not context:
554                         context={}
555                 (obj_dest,) = val
556                 definition_id = self._field_get(cr, uid, obj._name, prop)
557
558                 property = obj.pool.get('ir.property')
559                 nid = property.search(cr, uid, [('fields_id', '=', definition_id),
560                         ('res_id', '=', obj._name+','+str(id))])
561                 while len(nid):
562                         cr.execute('DELETE FROM ir_property WHERE id=%d', (nid.pop(),))
563
564                 nid = property.search(cr, uid, [('fields_id', '=', definition_id),
565                         ('res_id', '=', False)])
566                 default_val = False
567                 if nid:
568                         default_val = property.browse(cr, uid, nid[0], context).value
569
570                 company_id = obj.pool.get('res.users').company_get(cr, uid, uid)
571                 res = False
572                 newval = (id_val and obj_dest+','+str(id_val)) or False
573                 if (newval != default_val) and newval:
574                         propdef = obj.pool.get('ir.model.fields').browse(cr, uid,
575                                         definition_id, context=context)
576                         res = property.create(cr, uid, {
577                                 'name': propdef.name,
578                                 'value': newval,
579                                 'res_id': obj._name+','+str(id),
580                                 'company_id': company_id,
581                                 'fields_id': definition_id
582                         }, context=context)
583                 return res
584
585         def _fnct_read(self, obj, cr, uid, ids, prop, val, context=None):
586                 if not context:
587                         context={}
588                 property = obj.pool.get('ir.property')
589                 definition_id = self._field_get(cr, uid, obj._name, prop)
590
591                 nid = property.search(cr, uid, [('fields_id', '=', definition_id),
592                         ('res_id', '=', False)])
593                 default_val = False
594                 if nid:
595                         d = property.browse(cr, uid, nid[0], context).value
596                         default_val = (d and int(d.split(',')[1])) or False
597
598                 vids = [obj._name + ',' + str(id) for id in  ids]
599                 nids = property.search(cr, uid, [('fields_id', '=', definition_id),
600                         ('res_id', 'in', vids)])
601
602                 res = {}
603                 for id in ids:
604                         res[id]= default_val
605                 for prop in property.browse(cr, uid, nids):
606                         res[int(prop.res_id.split(',')[1])] = (prop.value and \
607                                         int(prop.value.split(',')[1])) or False
608
609                 obj = obj.pool.get(self._obj)
610                 names = dict(obj.name_get(cr, uid, filter(None, res.values()), context))
611                 for r in res.keys():
612                         if res[r] and res[r] in names:
613                                 res[r] = (res[r], names[res[r]])
614                         else:
615                                 res[r] = False
616                 return res
617
618         def _field_get(self, cr, uid, model_name, prop):
619                 if not self.field_id.get(cr.dbname):
620                         cr.execute('SELECT id \
621                                         FROM ir_model_fields \
622                                         WHERE name=%s AND model=%s', (prop, model_name))
623                         res = cr.fetchone()
624                         self.field_id[cr.dbname] = res and res[0]
625                 return self.field_id[cr.dbname]
626
627         def __init__(self, obj_prop, **args):
628                 self.field_id = {}
629                 function.__init__(self, self._fnct_read, False, self._fnct_write,
630                                 (obj_prop, ), **args)
631
632         def restart(self):
633                 self.field_id = {}