[IMP]:merged from trunk

bzr revid: apa@tinyerp.com-20100907043745-lpomcuk5z7mikmed
This commit is contained in:
apa-tiny
2010-09-07 10:07:45 +05:30
6 changed files with 48 additions and 34 deletions
+20 -7
View File
@@ -1067,7 +1067,7 @@
<field name="company_id" ref="main_company"/>
</record>
<!-- The Following currency rates are considered as 3rd sep,2010 against EUR. -->
<!-- The Following currency rates are considered as on 1st Jan,2010 against EUR. -->
<!-- Currencies -->
<record id="EUR" model="res.currency">
<field name="company_id" ref="main_company"/>
@@ -1167,7 +1167,7 @@
<field name="company_id" ref="main_company"/>
</record>
<record id="rateCOP" model="res.currency.rate">
<field name="rate">2332.91</field>
<field name="rate">2933.8378</field>
<field name="currency_id" ref="COP"/>
<field eval="time.strftime('%Y-01-01')" name="name"/>
</record>
@@ -1181,7 +1181,7 @@
<field name="company_id" ref="main_company"/>
</record>
<record id="rateCZK" model="res.currency.rate">
<field name="rate">24.6682</field>
<field name="rate">26.5634</field>
<field name="currency_id" ref="CZK"/>
<field eval="time.strftime('%Y-01-01')" name="name"/>
</record>
@@ -1210,10 +1210,24 @@
<field name="company_id" ref="main_company"/>
</record>
<record id="rateHUF" model="res.currency.rate">
<field name="rate">284.1004</field>
<field name="rate">271.5621</field>
<field name="currency_id" ref="HUF"/>
<field eval="time.strftime('%Y-01-01')" name="name"/>
</record>
<record id="IDR" model="res.currency">
<field name="name">Rs</field>
<field name="code">IDR</field>
<field name="symbol">Rs</field>
<field name="rounding">0.01</field>
<field name="accuracy">4</field>
<field name="company_id" ref="main_company"/>
</record>
<record id="rateIDR" model="res.currency.rate">
<field name="rate">13495.2056</field>
<field name="currency_id" ref="IDR"/>
<field eval="time.strftime('%Y-01-01')" name="name"/>
</record>
<record id="LVL" model="res.currency">
<field name="name">Ls</field>
@@ -1268,12 +1282,11 @@
<field name="company_id" ref="main_company"/>
</record>
<record id="ratePLN" model="res.currency.rate">
<field name="rate">3.9416</field>
<field name="rate">4.1005</field>
<field name="currency_id" ref="PLN"/>
<field eval="time.strftime('%Y-01-01')" name="name"/>
</record>
<record id="SEK" model="res.currency">
<field name="name">kr</field>
<field name="code">SEK</field>
@@ -1283,7 +1296,7 @@
<field name="company_id" ref="main_company"/>
</record>
<record id="rateSEK" model="res.currency.rate">
<field name="rate">9.2981</field>
<field name="rate">10.3004</field>
<field name="currency_id" ref="SEK"/>
<field eval="time.strftime('%Y-01-01')" name="name"/>
</record>
+18 -16
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@@ -50,7 +50,7 @@ class ir_cron(osv.osv, netsvc.Agent):
'interval_number': fields.integer('Interval Number'),
'interval_type': fields.selection( [('minutes', 'Minutes'),
('hours', 'Hours'), ('work_days','Work Days'), ('days', 'Days'),('weeks', 'Weeks'), ('months', 'Months')], 'Interval Unit'),
'numbercall': fields.integer('Number of Calls', help='Number of time the function is called,\na negative number indicates that the function will always be called'),
'numbercall': fields.integer('Number of Calls', help='Number of time the function is called,\na negative number indicates that the function will always be called'),
'doall' : fields.boolean('Repeat Missed'),
'nextcall' : fields.datetime('Next Call Date', required=True),
'model': fields.char('Object', size=64),
@@ -77,7 +77,7 @@ class ir_cron(osv.osv, netsvc.Agent):
except:
return False
return True
_constraints = [
(_check_args, 'Invalid arguments', ['args']),
]
@@ -98,7 +98,7 @@ class ir_cron(osv.osv, netsvc.Agent):
try:
db, pool = pooler.get_db_and_pool(db_name)
except:
return False
return False
cr = db.cursor()
try:
if not pool._init:
@@ -107,7 +107,7 @@ class ir_cron(osv.osv, netsvc.Agent):
for job in cr.dictfetchall():
nextcall = datetime.strptime(job['nextcall'], '%Y-%m-%d %H:%M:%S')
numbercall = job['numbercall']
ok = False
while nextcall < now and numbercall:
if numbercall > 0:
@@ -125,12 +125,12 @@ class ir_cron(osv.osv, netsvc.Agent):
cr.execute('select min(nextcall) as min_next_call from ir_cron where numbercall<>0 and active and nextcall>=now()')
next_call = cr.dictfetchone()['min_next_call']
next_call = cr.dictfetchone()['min_next_call']
if next_call:
next_call = time.mktime(time.strptime(next_call, '%Y-%m-%d %H:%M:%S'))
else:
next_call = int(time.time()) + 3600 # if do not find active cron job from database, it will run again after 1 day
if not check:
self.setAlarm(self._poolJobs, next_call, db_name, db_name)
@@ -138,29 +138,31 @@ class ir_cron(osv.osv, netsvc.Agent):
logger = netsvc.Logger()
logger.notifyChannel('cron', netsvc.LOG_WARNING,
'Exception in cron:'+str(ex))
finally:
cr.commit()
cr.close()
def restart(self, dbname):
self.cancel(dbname)
self._poolJobs(dbname)
def create(self, cr, uid, vals, context=None):
res = super(ir_cron, self).create(cr, uid, vals, context=context)
res = super(ir_cron, self).create(cr, uid, vals, context=context)
cr.commit()
self.cancel(cr.dbname)
self._poolJobs(cr.dbname)
self.restart(cr.dbname)
return res
def write(self, cr, user, ids, vals, context=None):
res = super(ir_cron, self).write(cr, user, ids, vals, context=context)
cr.commit()
self.cancel(cr.dbname)
self._poolJobs(cr.dbname)
self.restart(cr.dbname)
return res
def unlink(self, cr, uid, ids, context=None):
res = super(ir_cron, self).unlink(cr, uid, ids, context=context)
cr.commit()
self.cancel(cr.dbname)
self._poolJobs(cr.dbname)
self.restart(cr.dbname)
return res
ir_cron()
+1 -1
View File
@@ -167,7 +167,7 @@ LEVEL_COLOR_MAPPING = {
class DBFormatter(logging.Formatter):
def format(self, record):
record.dbname = getattr(threading.current_thread(), 'dbname', '?')
record.dbname = getattr(threading.currentThread(), 'dbname', '?')
return logging.Formatter.format(self, record)
class ColoredFormatter(DBFormatter):
+1 -1
View File
@@ -443,7 +443,7 @@ class orm_template(object):
if context.get('field_name', '') == k:
vals['select_level'] = context.get('select', '0')
#setting value to let the problem NOT occur next time
else:
elif k in cols:
vals['select_level'] = cols[k]['select_level']
if k not in cols:
+5 -6
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -34,10 +34,10 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False,
import osv.osv
pool = osv.osv.osv_pool()
pool_dic[db_name] = pool
try:
addons.load_modules(db, force_demo, status, update_module)
except Exception, e:
except Exception:
del pool_dic[db_name]
raise
@@ -51,13 +51,12 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False,
import report
report.interface.register_all(db)
if pooljobs:
pool.get('ir.cron')._poolJobs(db.dbname)
pool.get('ir.cron').restart(db.dbname)
return db, pool
def restart_pool(db_name, force_demo=False, status=None, update_module=False):
if db_name in pool_dic:
pool_dic[db_name].get('ir.cron').cancel(db_name)
del pool_dic[db_name]
return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
+3 -3
View File
@@ -21,7 +21,7 @@
__all__ = ['db_connect', 'close_db']
from threading import current_thread
from threading import currentThread
import logging
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED, ISOLATION_LEVEL_SERIALIZABLE
from psycopg2.psycopg1 import cursor as psycopg1cursor
@@ -365,13 +365,13 @@ def dsn_are_equals(first, second):
_Pool = ConnectionPool(int(tools.config['db_maxconn']))
def db_connect(db_name):
current_thread().dbname = db_name
currentThread().dbname = db_name
return Connection(_Pool, db_name)
def close_db(db_name):
_Pool.close_all(dsn(db_name))
tools.cache.clean_caches_for_db(db_name)
ct = current_thread()
ct = currentThread()
if hasattr(ct, 'dbname'):
delattr(ct, 'dbname')