[IMP] orm: minor cleanup: avoid duplicate functions to do the same thing
bzr revid: odo@openerp.com-20110922172027-7kiae4yd2vuwwk6w
This commit is contained in:
parent
aece39ac83
commit
7d4cdb69f2
|
@ -221,13 +221,6 @@ def OR(domains):
|
|||
"""OR([D1,D2,...]) returns a domain representing D1 or D2 or ... """
|
||||
return combine(OR_OPERATOR, FALSE_DOMAIN, TRUE_DOMAIN, domains)
|
||||
|
||||
# Probably bad style: the domain should be already normalized (and non-empty).
|
||||
def expression_and(term, domain):
|
||||
if domain:
|
||||
return ['&', term] + normalize(domain)
|
||||
else:
|
||||
return term
|
||||
|
||||
def is_operator(element):
|
||||
"""Test whether an object is a valid domain operator. """
|
||||
return isinstance(element, basestring) and element in DOMAIN_OPERATORS
|
||||
|
|
|
@ -21,19 +21,20 @@
|
|||
|
||||
#.apidoc title: Objects Services (OSV)
|
||||
|
||||
import logging
|
||||
from psycopg2 import IntegrityError, errorcodes
|
||||
|
||||
import orm
|
||||
import openerp
|
||||
import openerp.netsvc as netsvc
|
||||
import openerp.pooler as pooler
|
||||
import openerp.sql_db as sql_db
|
||||
import logging
|
||||
from psycopg2 import IntegrityError, errorcodes
|
||||
import expression # must not be first local import!
|
||||
from openerp.tools.config import config
|
||||
from openerp.tools.func import wraps
|
||||
from openerp.tools.translate import translate
|
||||
from openerp.osv.orm import MetaModel, Model
|
||||
|
||||
|
||||
class except_osv(Exception):
|
||||
def __init__(self, name, value, exc_type='warning'):
|
||||
self.name = name
|
||||
|
@ -289,11 +290,9 @@ class TransientModel(Model):
|
|||
return super(TransientModel, self).create(cr, uid, vals, context)
|
||||
|
||||
def _search(self, cr, uid, domain, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
|
||||
|
||||
# Restrict acces to the current user, except for the super-user.
|
||||
if self._log_access and uid != openerp.SUPERUSER:
|
||||
import expression
|
||||
domain = expression.expression_and(('create_uid', '=', uid), domain)
|
||||
domain = expression.AND(([('create_uid', '=', uid)], domain))
|
||||
|
||||
# TODO unclear: shoudl access_rights_uid be set to None (effectively ignoring it) or used instead of uid?
|
||||
return super(TransientModel, self)._search(cr, uid, domain, offset, limit, order, context, count, access_rights_uid)
|
||||
|
|
Loading…
Reference in New Issue