2009-07-07 19:35:44 +02:00
|
|
|
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
|
|
|
#this repository contains the full copyright notices and license terms.
|
2009-10-31 19:33:45 +01:00
|
|
|
from trytond.backend import fields
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Boolean(fields.Boolean):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_format(value):
|
|
|
|
|
return value and '1' or '0'
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('BOOLEAN', 'BOOLEAN')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Integer(fields.Integer):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('INTEGER', 'INTEGER')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class BigInteger(fields.BigInteger, Integer):
|
|
|
|
|
pass
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Char(fields.Char):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('VARCHAR', 'VARCHAR')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Sha(fields.Sha):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('VARCHAR', 'VARCHAR(40)')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Text(fields.Text):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('TEXT', 'TEXT')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Float(fields.Float):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('FLOAT', 'FLOAT')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Numeric(fields.Numeric):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('NUMERIC', 'NUMERIC')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Date(fields.Date):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('DATE', 'DATE')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class DateTime(fields.DateTime):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('TIMESTAMP', 'TIMESTAMP')
|
|
|
|
|
|
|
|
|
|
|
2009-11-10 14:00:13 +01:00
|
|
|
class Timestamp(fields.Timestamp):
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('TIMESTAMP', 'TIMESTAMP')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Time(fields.Time):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('TIME', 'TIME')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Binary(fields.Binary):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('BLOB', 'BLOB')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Selection(fields.Selection):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('VARCHAR', 'VARCHAR')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Reference(fields.Reference):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('VARCHAR', 'VARCHAR')
|
|
|
|
|
|
|
|
|
|
|
2009-10-31 19:33:45 +01:00
|
|
|
class Many2One(fields.Many2One):
|
2009-07-07 19:35:44 +02:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def sql_type(field):
|
|
|
|
|
return ('INTEGER', 'INTEGER')
|
|
|
|
|
|
|
|
|
|
FIELDS = {
|
|
|
|
|
'boolean': Boolean,
|
|
|
|
|
'integer': Integer,
|
|
|
|
|
'biginteger': BigInteger,
|
|
|
|
|
'char': Char,
|
|
|
|
|
'sha': Sha,
|
|
|
|
|
'text': Text,
|
|
|
|
|
'float': Float,
|
|
|
|
|
'numeric': Numeric,
|
|
|
|
|
'date': Date,
|
|
|
|
|
'datetime': DateTime,
|
2009-11-10 14:00:13 +01:00
|
|
|
'timestamp': Timestamp,
|
2009-07-07 19:35:44 +02:00
|
|
|
'time': Time,
|
|
|
|
|
'binary': Binary,
|
|
|
|
|
'selection': Selection,
|
|
|
|
|
'reference': Reference,
|
|
|
|
|
'many2one': Many2One,
|
2009-10-31 19:33:45 +01:00
|
|
|
'one2many': fields.One2Many,
|
|
|
|
|
'many2many': fields.Many2Many,
|
|
|
|
|
'function': fields.Function,
|
|
|
|
|
'property': fields.Property,
|
2009-07-07 19:35:44 +02:00
|
|
|
}
|