diff --git a/trytond/ir/action.py b/trytond/ir/action.py index eb7e177018..99392452d9 100644 --- a/trytond/ir/action.py +++ b/trytond/ir/action.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "Action" from trytond.osv import fields, OSV from trytond.tools import file_open @@ -8,10 +9,10 @@ class Action(OSV): "Action" _name = 'ir.action' _description = __doc__ - name = fields.char('Name', required=True, translate=True) - type = fields.char('Type', required=True, readonly=True) - usage = fields.char('Usage') - keywords = fields.one2many('ir.action.keyword', 'action', + name = fields.Char('Name', required=True, translate=True) + type = fields.Char('Type', required=True, readonly=True) + usage = fields.Char('Usage') + keywords = fields.One2Many('ir.action.keyword', 'action', 'Keywords') groups = fields.Many2Many('res.group', 'ir_action_group_rel', 'action_id', 'gid', 'Groups') @@ -62,7 +63,7 @@ class ActionKeyword(OSV): ('graph_open', 'Open Graph'), ], string='Keyword', required=True) model = fields.Reference('Model', selection='models_get') - action = fields.many2one('ir.action', 'Action', + action = fields.Many2One('ir.action', 'Action', ondelete='CASCADE') def __init__(self): @@ -174,9 +175,9 @@ class ActionReportOutputFormat(OSV): "Output formats for reports" _name = 'ir.action.report.outputformat' _description = "Report Output Format" - format = fields.char('Internal Format Name', required=True, + format = fields.Char('Internal Format Name', required=True, readonly=True, help="Used as file extension, too.") - name = fields.char('Name', required=True, translate=True) + name = fields.Char('Name', required=True, translate=True) ActionReportOutputFormat() @@ -374,8 +375,8 @@ class ActionWizard(OSV): _sequence = 'ir_action_id_seq' _description = __doc__ _inherits = {'ir.action': 'action'} - wiz_name = fields.char('Wizard name', required=True) - action = fields.many2one('ir.action', 'Action', required=True) + wiz_name = fields.Char('Wizard name', required=True) + action = fields.Many2One('ir.action', 'Action', required=True) def default_type(self, cursor, user, context=None): return 'ir.action.wizard' @@ -390,7 +391,7 @@ class ActionURL(OSV): _description = __doc__ _inherits = {'ir.action': 'action'} url = fields.Char('Action Url', required=True) - action = fields.many2one('ir.action', 'Action', required=True) + action = fields.Many2One('ir.action', 'Action', required=True) def default_type(self, cursor, user, context=None): return 'ir.action.url' diff --git a/trytond/ir/export.py b/trytond/ir/export.py index e764c26c8f..8161b63cf9 100644 --- a/trytond/ir/export.py +++ b/trytond/ir/export.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "Exports" from trytond.osv import fields, OSV @@ -7,9 +8,9 @@ class Export(OSV): "Export" _name = "ir.export" _description = __doc__ - name = fields.char('Export name', size=128) - resource = fields.char('Resource', size=128) - export_fields = fields.one2many('ir.export.line', 'export', + name = fields.Char('Export name', size=128) + resource = fields.Char('Resource', size=128) + export_fields = fields.One2Many('ir.export.line', 'export', 'Export Id') Export() @@ -19,8 +20,8 @@ class ExportLine(OSV): "Export line" _name = 'ir.export.line' _description = __doc__ - name = fields.char('Field name', size=64) - export = fields.many2one('ir.export', 'Exportation', + name = fields.Char('Field name', size=64) + export = fields.Many2One('ir.export', 'Exportation', select=True) ExportLine() diff --git a/trytond/ir/ui/menu.py b/trytond/ir/ui/menu.py index cc1aff65b5..aa6df2b2f9 100644 --- a/trytond/ir/ui/menu.py +++ b/trytond/ir/ui/menu.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "UI menu" from trytond.osv import fields, OSV @@ -83,7 +84,7 @@ class UIMenu(OSV): 'menu_id', 'gid', 'Groups') complete_name = fields.Function('get_full_name', string='Complete Name', type='char', order_field='name') - icon = fields.selection(ICONS, 'Icon') + icon = fields.Selection(ICONS, 'Icon') action = fields.Function('get_action', fnct_inv='action_inv', type='reference', string='Action', selection=[ diff --git a/trytond/osv/fields.py b/trytond/osv/fields.py index 00f2bb4dbc..473d463520 100644 --- a/trytond/osv/fields.py +++ b/trytond/osv/fields.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. """ Fields: - simple @@ -98,8 +99,6 @@ class Boolean(Column): def sql_type(self): return ('bool', 'bool') -boolean = Boolean - class Integer(Column): _type = 'integer' @@ -110,8 +109,6 @@ class Integer(Column): def sql_type(self): return ('int4', 'int4') -integer = Integer - class Reference(Column): _type = 'reference' @@ -167,8 +164,6 @@ class Reference(Column): else: return ('varchar', 'varchar') -reference = Reference - class Char(Column): _type = 'char' @@ -182,8 +177,6 @@ class Char(Column): else: return ('varchar', 'varchar') -char = Char - class Sha(Column): _type = 'sha' @@ -203,8 +196,6 @@ class Text(Column): def sql_type(self): return ('text', 'text') -text = Text - class Float(Column): _type = 'float' @@ -219,8 +210,6 @@ class Float(Column): def sql_type(self): return ('float8', 'float8') -float = Float - class Numeric(Float): _type = 'numeric' @@ -228,8 +217,6 @@ class Numeric(Float): def sql_type(self): return ('numeric', 'numeric') -numeric = Numeric - class Date(Column): _type = 'date' @@ -237,8 +224,6 @@ class Date(Column): def sql_type(self): return ('date', 'date') -date = Date - class DateTime(Column): _type = 'datetime' @@ -246,8 +231,6 @@ class DateTime(Column): def sql_type(self): return ('timestamp', 'timestamp(0)') -datetime = DateTime - class Time(Column): _type = 'time' @@ -255,8 +238,6 @@ class Time(Column): def sql_type(self): return ('time', 'time') -time = Time - class Binary(Column): _type = 'binary' @@ -268,8 +249,6 @@ class Binary(Column): def sql_type(self): return ('bytea', 'bytea') -binary = Binary - class Selection(Column): _type = 'selection' @@ -287,8 +266,6 @@ class Selection(Column): else: return ('varchar', 'varchar') -selection = Selection - class Many2One(Column): _classic_read = False @@ -365,8 +342,6 @@ class Many2One(Column): def sql_type(self): return ('int4', 'int4') -many2one = Many2One - class One2Many(Column): _classic_read = False @@ -466,8 +441,6 @@ class One2Many(Column): else: raise Exception('Bad arguments') -one2many = One2Many - class Many2Many(Column): _classic_read = False @@ -593,8 +566,6 @@ class Many2Many(Column): else: raise Exception('Bad arguments') -many2many = Many2Many - class Function(Column): _classic_read = False @@ -617,8 +588,8 @@ class Function(Column): self.readonly = 1 self._type = type self._fnct_search = fnct_search - self._symbol_c = eval(self._type)._symbol_c - self._symbol_f = eval(self._type)._symbol_f + self._symbol_c = _TYPE2CLASS[self._type]._symbol_c + self._symbol_f = _TYPE2CLASS[self._type]._symbol_f self._symbol_set = (self._symbol_c, self._symbol_f) def search(self, cursor, user, obj, name, args, context=None): @@ -652,8 +623,6 @@ class Function(Column): getattr(obj, self._fnct_inv)(cursor, user, obj_id, name, value, self._fnct_inv_arg, context=context) -function = Function - class Property(Function): @@ -682,7 +651,7 @@ class Property(Function): return res def __init__(self, **args): - function.__init__(self, '', None, self._fnct_write, None, **args) + super(Property, self).__init__('', None, self._fnct_write, None, **args) def get(self, cursor, obj, ids, name, user=None, offset=0, context=None, values=None): @@ -693,4 +662,9 @@ class Property(Function): self._fnct_write(obj, cursor, user, obj_id, name, value, self._obj, context=context) -property = Property +_TYPE2CLASS = { +} + +for klass in (Boolean, Integer, Reference, Char, Sha, Text, Float, Numeric, + Date, DateTime, Time, Binary, Selection, Many2One, One2Many, Many2Many): + _TYPE2CLASS[klass._type] = klass diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 29a7ef37b9..d40c6757e6 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. # -*- coding: utf-8 -*- from trytond.netsvc import LocalService import fields @@ -39,10 +40,11 @@ class BrowseRecordList(list): res.append(res2) return res -browse_record_list = BrowseRecordList - class BrowseRecordNull(object): + ''' + An object that represents an empty record. + ''' def __init__(self): self.id = False @@ -59,9 +61,10 @@ class BrowseRecordNull(object): def __nonzero__(self): return False + class BrowseRecord(object): ''' - A object that represents record defined by a ORM object. + An object that represents record defined by a ORM object. ''' def __init__(self, cursor, user, object_id, table, cache, context=None): @@ -215,8 +218,6 @@ class BrowseRecord(object): res = res.get_eval() return res -browse_record = BrowseRecord - class EvalEnvironment(dict): @@ -3019,5 +3020,3 @@ class ORM(object): + str(max_right + 1 - (old_left or -1)) + ' ' \ 'WHERE "' + left + '" >= %s AND "' + right + '" <= %s', (old_left, old_right)) - -orm = ORM diff --git a/trytond/osv/osv.py b/trytond/osv/osv.py index 76c1f3d0d0..5a6d0e309e 100644 --- a/trytond/osv/osv.py +++ b/trytond/osv/osv.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "Objects Services" from orm import ORM @@ -156,8 +157,6 @@ class OSVService(Service): inst._sql_error_messages[key] return res -osv_pool = OSVService - class OSV(ORM): @@ -193,8 +192,6 @@ class OSV(ORM): def __init__(self): super(OSV, self).__init__() -osv = OSV - class Cacheable(object): diff --git a/trytond/res/user.py b/trytond/res/user.py index 1636583f3d..15de106629 100644 --- a/trytond/res/user.py +++ b/trytond/res/user.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "User" import copy from trytond.osv import fields, OSV @@ -270,7 +271,7 @@ User() class Group(OSV): _name = 'res.group' - users = fields.many2many( + users = fields.Many2Many( 'res.user', 'res_group_user_rel', 'gid', 'uid', 'Users') Group()