Add One2One field

This commit is contained in:
Cédric Krier
2010-12-03 18:00:06 +01:00
parent abef529665
commit 84d9edeb1e
8 changed files with 24 additions and 3 deletions
+2
View File
@@ -1,3 +1,5 @@
* Add One2One field
Version 1.8.0 - 2010-11-01
* Bug fixes (see mercurial logs for details)
* More fully integrate GTK menubar for Mac OS
@@ -332,6 +332,10 @@ class M2OField(CharField):
return context
class O2OField(M2OField):
pass
class O2MField(CharField):
'''
internal = Group of the related objects
@@ -666,4 +670,5 @@ TYPES = {
'boolean': BooleanField,
'datetime': DateTimeField,
'date': DateField,
'one2one': O2OField,
}
+1 -1
View File
@@ -95,7 +95,7 @@ class Record(SignalEvent):
ids, self.group.fields.keys() + \
[x + '.rec_name' for x in self.group.fields.keys()
if self.group.fields[x].attrs['type'] \
in ('many2one', 'reference')] + \
in ('many2one', 'one2one', 'reference')] + \
['_timestamp'], ctx)
try:
values = rpc.execute(*args)
@@ -0,0 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from many2one import Many2One
class One2One(Many2One):
pass
@@ -827,6 +827,7 @@ from many2one import Many2One
from url import Email, URL, CallTo, SIP
from image import Image as Image2
from progressbar import ProgressBar
from one2one import One2One
WIDGETS_TYPE = {
@@ -853,4 +854,5 @@ WIDGETS_TYPE = {
'sip' : (SIP, 1, False, False),
'image' : (Image2, 1, False, False),
'progressbar': (ProgressBar, 1, False, False),
'one2one': (One2One, 1, False, False),
}
@@ -572,6 +572,9 @@ class M2O(Char):
else:
return False, None
class O2O(M2O):
pass
class UnsettableColumn(Exception):
def __init__(self):
@@ -911,4 +914,5 @@ CELLTYPES = {
'sip': Char,
'progressbar': ProgressBar,
'reference': Reference,
'one2one': O2O,
}
@@ -317,4 +317,5 @@ WIDGETS_TYPE = {
'many2many': (char.Char, 2),
'callto': (char.Char, 2),
'sip': (char.Char, 2),
'one2one': (char.Char, 2),
}
+2 -2
View File
@@ -90,7 +90,7 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
pass
obj[field] = common.datetime_strftime(obj[field],
display_format)
elif field_type in ('many2one',):
elif field_type in ('many2one', 'one2one'):
for obj in res_ids:
if obj[field]:
obj[field] = obj[field + '.rec_name']
@@ -144,7 +144,7 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
tree = []
fields = self.fields_type.keys()
for field_name in self.fields_type:
if self.fields_type[field_name]['type'] == 'many2one':
if self.fields_type[field_name]['type'] in ('many2one', 'one2one'):
fields.append(field_name + '.rec_name')
if self.view.get('field_childs', False):
res = self._read(ids, fields + [self.view['field_childs']])