diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 568a52f2bf4..4e8eedf718b 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -1067,6 +1067,8 @@ class function(_column): self._classic_write = True if type=='binary': self._symbol_get=lambda x:x and str(x) + else: + self._prefetch = True if type == 'float': self._symbol_c = float._symbol_c diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index eb5f637622b..eefe013cc42 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -385,11 +385,11 @@ class browse_record(object): # if the field is a classic one or a many2one, we'll fetch all classic and many2one fields if col._prefetch: # gen the list of "local" (ie not inherited) fields which are classic or many2one - fields_to_fetch = filter(lambda x: x[1]._classic_write, self._table._columns.items()) + fields_to_fetch = filter(lambda x: x[1]._classic_write and x[1]._prefetch, self._table._columns.items()) # gen the list of inherited fields inherits = map(lambda x: (x[0], x[1][2]), self._table._inherit_fields.items()) # complete the field list with the inherited fields which are classic or many2one - fields_to_fetch += filter(lambda x: x[1]._classic_write, inherits) + fields_to_fetch += filter(lambda x: x[1]._classic_write and x[1]._prefetch, inherits) # otherwise we fetch only that field else: fields_to_fetch = [(name, col)] @@ -1034,6 +1034,7 @@ class BaseModel(object): 'ondelete': field['on_delete'], 'translate': (field['translate']), 'manual': True, + '_prefetch': False, #'select': int(field['select_level']) } diff --git a/openerp/report/render/rml2pdf/utils.py b/openerp/report/render/rml2pdf/utils.py index ae70cd46c94..6fce8106b49 100644 --- a/openerp/report/render/rml2pdf/utils.py +++ b/openerp/report/render/rml2pdf/utils.py @@ -116,10 +116,13 @@ def _process_text(self, txt): result += tools.ustr(self.localcontext.get('translate', lambda x:x)(to_translate)) if sps: txt = None - expr = sps.pop(0) - txt = eval(expr, self.localcontext) - if txt and isinstance(txt, basestring): - txt = tools.ustr(txt) + try: + expr = sps.pop(0) + txt = eval(expr, self.localcontext) + if txt and isinstance(txt, basestring): + txt = tools.ustr(txt) + except Exception: + _logger.error("Failed to evaluate expression [[ %s ]] with context %r while rendering report, ignored.", expr, self.localcontext) if isinstance(txt, basestring): result += txt elif txt and (txt is not None) and (txt is not False): diff --git a/openerp/service/workers.py b/openerp/service/workers.py index 1075342919d..8fec2767471 100644 --- a/openerp/service/workers.py +++ b/openerp/service/workers.py @@ -196,7 +196,7 @@ class Multicorn(object): def stop(self, graceful=True): if self.long_polling_pid is not None: - self.worker_kill(self.long_polling_pid, signal.SIGTERM) + self.worker_kill(self.long_polling_pid, signal.SIGKILL) # FIXME make longpolling process handle SIGTERM correctly self.long_polling_pid = None if graceful: _logger.info("Stopping gracefully") @@ -392,14 +392,18 @@ class WorkerCron(Worker): interval = 60 + self.pid % 10 # chorus effect time.sleep(interval) - def process_work(self): - rpc_request = logging.getLogger('openerp.netsvc.rpc.request') - rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG) - _logger.debug("WorkerCron (%s) polling for jobs", self.pid) + def _db_list(self): if config['db_name']: db_names = config['db_name'].split(',') else: db_names = openerp.service.db.exp_list(True) + return db_names + + def process_work(self): + rpc_request = logging.getLogger('openerp.netsvc.rpc.request') + rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG) + _logger.debug("WorkerCron (%s) polling for jobs", self.pid) + db_names = self._db_list() if len(db_names): self.db_index = (self.db_index + 1) % len(db_names) db_name = db_names[self.db_index] @@ -433,8 +437,15 @@ class WorkerCron(Worker): self.db_index = 0 def start(self): + os.nice(10) # mommy always told me to be nice with others... Worker.start(self) self.multi.socket.close() openerp.service.start_internal() + # chorus effect: make cron workers do not all start at first database + mct = config['max_cron_threads'] + p = float(self.pid % mct) / mct + self.db_index = int(len(self._db_list()) * p) + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: