[MERGE] forward port of branch 8.0 up to c345d29
This commit is contained in:
@@ -32,6 +32,7 @@ from openerp import SUPERUSER_ID, models
|
||||
from openerp import tools
|
||||
import openerp.exceptions
|
||||
from openerp.osv import fields, osv, expression
|
||||
from openerp.service.security import check_super
|
||||
from openerp.tools.translate import _
|
||||
from openerp.http import request
|
||||
from openerp.exceptions import UserError
|
||||
@@ -426,10 +427,7 @@ class res_users(osv.osv):
|
||||
return dataobj.browse(cr, uid, data_id, context=context).res_id
|
||||
|
||||
def check_super(self, passwd):
|
||||
if passwd == tools.config['admin_passwd']:
|
||||
return True
|
||||
else:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
return check_super(passwd)
|
||||
|
||||
def check_credentials(self, cr, uid, password):
|
||||
""" Override this method to plug additional authentication methods"""
|
||||
|
||||
+6
-2
@@ -1202,13 +1202,15 @@ class Date(Field):
|
||||
@staticmethod
|
||||
def from_string(value):
|
||||
""" Convert an ORM ``value`` into a :class:`date` value. """
|
||||
if not value:
|
||||
return None
|
||||
value = value[:DATE_LENGTH]
|
||||
return datetime.strptime(value, DATE_FORMAT).date()
|
||||
|
||||
@staticmethod
|
||||
def to_string(value):
|
||||
""" Convert a :class:`date` value into the format expected by the ORM. """
|
||||
return value.strftime(DATE_FORMAT)
|
||||
return value.strftime(DATE_FORMAT) if value else False
|
||||
|
||||
def convert_to_cache(self, value, record, validate=True):
|
||||
if not value:
|
||||
@@ -1266,6 +1268,8 @@ class Datetime(Field):
|
||||
@staticmethod
|
||||
def from_string(value):
|
||||
""" Convert an ORM ``value`` into a :class:`datetime` value. """
|
||||
if not value:
|
||||
return None
|
||||
value = value[:DATETIME_LENGTH]
|
||||
if len(value) == DATE_LENGTH:
|
||||
value += " 00:00:00"
|
||||
@@ -1274,7 +1278,7 @@ class Datetime(Field):
|
||||
@staticmethod
|
||||
def to_string(value):
|
||||
""" Convert a :class:`datetime` value into the format expected by the ORM. """
|
||||
return value.strftime(DATETIME_FORMAT)
|
||||
return value.strftime(DATETIME_FORMAT) if value else False
|
||||
|
||||
def convert_to_cache(self, value, record, validate=True):
|
||||
if not value:
|
||||
|
||||
+2
-1
@@ -1242,7 +1242,8 @@ class BaseModel(object):
|
||||
for fun, msg, names in self._constraints:
|
||||
try:
|
||||
# validation must be context-independent; call ``fun`` without context
|
||||
valid = not (set(names) & field_names) or fun(self._model, cr, uid, ids)
|
||||
valid = names and not (set(names) & field_names)
|
||||
valid = valid or fun(self._model, cr, uid, ids)
|
||||
extra_error = None
|
||||
except Exception, e:
|
||||
_logger.debug('Exception while validating constraint', exc_info=True)
|
||||
|
||||
@@ -27,10 +27,9 @@ def login(db, login, password):
|
||||
return res_users._login(db, login, password)
|
||||
|
||||
def check_super(passwd):
|
||||
if passwd == openerp.tools.config['admin_passwd']:
|
||||
if passwd and passwd == openerp.tools.config['admin_passwd']:
|
||||
return True
|
||||
else:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
|
||||
def check(db, uid, passwd):
|
||||
res_users = openerp.registry(db)['res.users']
|
||||
|
||||
Reference in New Issue
Block a user