[MERGE] Merged with server/trunk.

bzr revid: tde@openerp.com-20120813181359-s0hhsdp6ev7dtznr
bzr revid: tde@openerp.com-20120814114047-z3guxfe9zxmsrk46
This commit is contained in:
Thibault Delavallée 2012-08-14 13:40:47 +02:00
commit c9fda0b13a
4 changed files with 29 additions and 6 deletions

View File

@ -22,6 +22,7 @@
""" Models registries.
"""
from contextlib import contextmanager
import logging
import threading
@ -43,12 +44,12 @@ class Registry(object):
"""
def __init__(self, db_name):
self.models = {} # model name/model instance mapping
self.models = {} # model name/model instance mapping
self._sql_error = {}
self._store_function = {}
self._init = True
self._init_parent = {}
# modules fully loaded (maintained during init phase by `loading` module)
self._init_modules = set()
@ -119,6 +120,17 @@ class Registry(object):
for model in self.models.itervalues():
model.clear_caches()
@contextmanager
def cursor(self, auto_commit=True):
cr = self.db.cursor()
try:
yield cr
if auto_commit:
cr.commit()
finally:
cr.close()
class RegistryManager(object):
""" Model registries manager.
@ -196,7 +208,6 @@ class RegistryManager(object):
del cls.registries[db_name]
openerp.cron.cancel(db_name)
@classmethod
def delete_all(cls):
"""Delete all the registries. """

View File

@ -109,6 +109,7 @@ class _column(object):
self.selectable = True
self.group_operator = args.get('group_operator', False)
self.groups = False # CSV list of ext IDs of groups that can access this field
self.deprecated = False # Optional deprecation warning
for a in args:
if args[a]:
setattr(self, a, args[a])

View File

@ -3596,6 +3596,14 @@ class BaseModel(object):
record[f] = res2[record['id']]
else:
record[f] = []
# Warn about deprecated fields now that fields_pre and fields_post are computed
# Explicitly use list() because we may receive tuples
for f in list(fields_pre) + list(fields_post):
field_column = self._all_columns.get(f) and self._all_columns.get(f).column
if field_column and field_column.deprecated:
_logger.warning('Field %s.%s is deprecated: %s', self._name, f, field_column.deprecated)
readonly = None
for vals in res:
for field in vals.copy():
@ -3973,6 +3981,9 @@ class BaseModel(object):
direct = []
totranslate = context.get('lang', False) and (context['lang'] != 'en_US')
for field in vals:
field_column = self._all_columns.get(field) and self._all_columns.get(field).column
if field_column and field_column.deprecated:
_logger.warning('Field %s.%s is deprecated: %s', self._name, field, field_column.deprecated)
if field in self._columns:
if self._columns[field]._classic_write and not (hasattr(self._columns[field], '_fnct_inv')):
if (not totranslate) or not self._columns[field].translate:

View File

@ -30,9 +30,9 @@ RELEASE_LEVELS_DISPLAY = {ALPHA: ALPHA,
# properly comparable using normal operarors, for example:
# (6,1,0,'beta',0) < (6,1,0,'candidate',1) < (6,1,0,'candidate',2)
# (6,1,0,'candidate',2) < (6,1,0,'final',0) < (6,1,2,'final',0)
version_info = (6,2,0,ALPHA,0)
version = '.'.join(map(str,version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '')
major_version = '.'.join(map(str,version_info[:2]))
version_info = (7, 0, 0, ALPHA, 0)
version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '')
serie = major_version = '.'.join(map(str, version_info[:2]))
description = 'OpenERP Server'
long_desc = '''OpenERP is a complete ERP and CRM. The main features are accounting (analytic