From b38c97bd4afbb7b8de213204bb45a9aa95bffb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 17 Feb 2008 02:36:25 +0100 Subject: [PATCH] Fix inheritance in __init__ - Add field only if pool is not None - Don't append to mutable object because they are static in ORM object so they will be change for all objects --- trytond/ir/action.py | 7 ++++--- trytond/ir/module/module.py | 19 ++++++++++--------- trytond/ir/property.py | 9 +++++---- trytond/ir/rule.py | 7 ++++--- trytond/ir/sequence.py | 7 ++++--- trytond/ir/translation.py | 23 +++++++++++++---------- trytond/ir/ui/view.py | 7 ++++--- trytond/res/request.py | 15 ++++++++------- trytond/res/user.py | 20 +++++++++++--------- trytond/webdav/webdav.py | 5 +++-- 10 files changed, 66 insertions(+), 53 deletions(-) diff --git a/trytond/ir/action.py b/trytond/ir/action.py index c513db4473..8c99bc9496 100644 --- a/trytond/ir/action.py +++ b/trytond/ir/action.py @@ -61,9 +61,10 @@ class ActionKeyword(OSV): def __init__(self, pool): super(ActionKeyword, self).__init__(pool) - self._rpc_allowed.extend([ - 'get_keyword', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'get_keyword', + ] def _convert_vals(self, cursor, user, vals, context=None): vals = vals.copy() diff --git a/trytond/ir/module/module.py b/trytond/ir/module/module.py index a7a51d12ab..9ca94c3a73 100644 --- a/trytond/ir/module/module.py +++ b/trytond/ir/module/module.py @@ -166,15 +166,16 @@ class Module(OSV): def __init__(self, pool): super(Module, self).__init__(pool) - self._rpc_allowed.extend([ - 'button_install', - 'button_install_cancel', - 'button_uninstall', - 'button_uninstall_cancel', - 'button_upgrade', - 'button_upgrade_cancel', - 'button_update_translations', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'button_install', + 'button_install_cancel', + 'button_uninstall', + 'button_uninstall_cancel', + 'button_upgrade', + 'button_upgrade_cancel', + 'button_update_translations', + ] @staticmethod def get_module_info(name): diff --git a/trytond/ir/property.py b/trytond/ir/property.py index c336749329..74b8e32791 100644 --- a/trytond/ir/property.py +++ b/trytond/ir/property.py @@ -17,10 +17,11 @@ class Property(OSV): def __init__(self, pool): super(Property, self).__init__(pool) - self._rpc_allowed.extend([ - 'models_get2', - 'models_get', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'models_get2', + 'models_get', + ] def models_get2(self, cursor, user, context=None): model_fields_obj = self.pool.get('ir.model.fields') diff --git a/trytond/ir/rule.py b/trytond/ir/rule.py index e1f83ccf04..6f3894e237 100644 --- a/trytond/ir/rule.py +++ b/trytond/ir/rule.py @@ -75,9 +75,10 @@ class Rule(OSV): def __init__(self, pool): super(Rule, self).__init__(pool) - self._rpc_allowed.extend([ - 'operand', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'operand', + ] def operand(self, cursor, user, context): diff --git a/trytond/ir/sequence.py b/trytond/ir/sequence.py index d22f94e86d..159fe14e17 100644 --- a/trytond/ir/sequence.py +++ b/trytond/ir/sequence.py @@ -38,9 +38,10 @@ class Sequence(OSV): def __init__(self, pool): super(Sequence, self).__init__(pool) - self._rpc_allowed.extend([ - 'code_get', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'code_get', + ] def code_get(self, cursor, user, context=None): cursor.execute('select code, name from ir_sequence_type') diff --git a/trytond/ir/translation.py b/trytond/ir/translation.py index 67309d932a..10e1ed9972 100644 --- a/trytond/ir/translation.py +++ b/trytond/ir/translation.py @@ -56,9 +56,10 @@ class Translation(OSV, Cacheable): def __init__(self, pool): super(Translation, self).__init__(pool) - self._rpc_allowed.extend([ - 'get_language', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'get_language', + ] def model(self, cursor, user, ids, name, arg, context=None): res = {} @@ -376,9 +377,10 @@ class TranslationUpdateInit(WizardOSV): def __init__(self, pool): super(TranslationUpdateInit, self).__init__(pool) - self._rpc_allowed.extend([ - 'get_language', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'get_language', + ] def get_language(self, cursor, user, context): lang_obj = self.pool.get('ir.lang') @@ -508,10 +510,11 @@ class TranslationExportInit(WizardOSV): def __init__(self, pool): super(TranslationExportInit, self).__init__(pool) - self._rpc_allowed.extend([ - 'get_language', - 'get_module', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'get_language', + 'get_module', + ] def get_language(self, cursor, user, context): lang_obj = self.pool.get('ir.lang') diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index bb42d71690..6c6a1f1309 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -182,9 +182,10 @@ class ViewShortcut(OSV): def __init__(self, pool): super(ViewShortcut, self).__init__(pool) - self._rpc_allowed.extend([ - 'get_sc', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'get_sc', + ] def get_sc(self, cursor, user, user_id, model='ir.ui.menu', context=None): "Provide user's shortcuts" diff --git a/trytond/res/request.py b/trytond/res/request.py index c51c8f0b17..d8c9cceab5 100644 --- a/trytond/res/request.py +++ b/trytond/res/request.py @@ -67,13 +67,14 @@ class Request(OSV): def __init__(self, pool): super(Request, self).__init__(pool) - self._rpc_allowed.extend([ - 'links_get', - 'request_send', - 'request_reply', - 'request_close', - 'request_get', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'links_get', + 'request_send', + 'request_reply', + 'request_close', + 'request_get', + ] def links_get(self, cursor, user, context=None): request_link_obj = self.pool.get('res.request.link') diff --git a/trytond/res/user.py b/trytond/res/user.py index 69b24e96d8..4c0de69496 100644 --- a/trytond/res/user.py +++ b/trytond/res/user.py @@ -84,13 +84,14 @@ class User(OSV): def __init__(self, pool): super(User, self).__init__(pool) - self._rpc_allowed.extend([ - 'get_preferences', - 'set_preferences', - 'get_preferences_fields_view', - 'languages', - 'timezones', - ]) + if pool: + self._rpc_allowed = self._rpc_allowed + [ + 'get_preferences', + 'set_preferences', + 'get_preferences_fields_view', + 'languages', + 'timezones', + ] def _convert_vals(self, cursor, user, vals, context=None): vals = vals.copy() @@ -205,7 +206,8 @@ class Group2(Group): def __init__(self, pool): super(Group2, self).__init__(pool) - self._columns['users'] = fields.many2many( - 'res.user', 'res_group_user_rel', 'gid', 'uid', 'Users') + if pool: + self._columns['users'] = fields.many2many( + 'res.user', 'res_group_user_rel', 'gid', 'uid', 'Users') Group2() diff --git a/trytond/webdav/webdav.py b/trytond/webdav/webdav.py index 6e0c24feaf..ac1b4dfe59 100644 --- a/trytond/webdav/webdav.py +++ b/trytond/webdav/webdav.py @@ -301,12 +301,13 @@ class Attachment(OSV): def __init__(self, pool): super(Attachment, self).__init__(pool) - self._constraints = self._constraints + [ + if pool: + self._constraints = self._constraints + [ ('check_directory', 'Error! You can not create a attachment \n' \ 'on a directory that have the same name \n' \ 'than a child directory.', ['name']), - ] + ] def check_directory(self, cursor, user, ids): directory_obj = self.pool.get('webdav.directory')