[MERGE]: merging from the same branch

bzr revid: mga@tinyerp.com-20090916102642-c4niyojssbdwfso7
This commit is contained in:
Mantavya Gajjar
2009-09-16 15:56:42 +05:30
6 changed files with 75 additions and 19 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
# -*- makefile -*-
addons-path := bin/addons/
extra-addons:= ''
root-path := bin/
port := 8069
net_port := 8070
@@ -22,7 +23,7 @@ drop-db:
python $(interrogation_file) drop-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port)
install-module:
python $(interrogation_file) install-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --login=$(login) --password=$(password)
python $(interrogation_file) install-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --extra-addons=$(extra-addons) --port=$(port) --login=$(login) --password=$(password)
upgrade-module:
python $(interrogation_file) upgrade-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --login=$(login) --password=$(password)
+29 -9
View File
@@ -27,8 +27,6 @@ import tools
import pooler
from osv import fields,osv
next_wait = 60
_intervalTypes = {
'work_days': lambda interval: DateTime.RelativeDateTime(days=interval),
'days': lambda interval: DateTime.RelativeDateTime(days=interval),
@@ -74,20 +72,18 @@ class ir_cron(osv.osv, netsvc.Agent):
f = getattr(m, func)
f(cr, uid, *args)
def _poolJobs(self, db_name, check=False):
def _poolJobs(self, db_name, check=False):
try:
db, pool = pooler.get_db_and_pool(db_name)
except:
return False
return False
if pool._init:
# retry in a few minutes
next_call = 600
next_call = 600
else:
next_call = next_wait
cr = db.cursor()
now = DateTime.now()
try:
cr = db.cursor()
cr.execute('select * from ir_cron where numbercall<>0 and active and nextcall<=now() order by priority')
for job in cr.dictfetchall():
nextcall = DateTime.strptime(job['nextcall'], '%Y-%m-%d %H:%M:%S')
@@ -115,8 +111,32 @@ class ir_cron(osv.osv, netsvc.Agent):
# Can be improved to do at the min(min(nextcalls), time()+next_call)
# But is this an improvement ?
#
cr = db.cursor()
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']
cr.close()
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, int(time.time()) + next_call, db_name, db_name)
self.setAlarm(self._poolJobs, next_call, db_name, db_name)
def create(self, cr, uid, vals, context=None):
res = super(ir_cron, self).create(cr, uid, vals, context=context)
cr.commit()
self._poolJobs(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._poolJobs(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._poolJobs(cr.dbname)
return res
ir_cron()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -378,6 +378,7 @@
<rng:ref name="page" />
<rng:ref name="separator"/>
<rng:ref name="button"/>
<rng:ref name="group"/>
<rng:element name="properties"><rng:empty/></rng:element>
<rng:element name="newline"><rng:empty/></rng:element>
</rng:choice>
@@ -113,7 +113,7 @@ def check_quality(uri, user, pwd, dbname, modules):
test_detail = {}
for module in modules:
quality_result = execute(conn,'execute', dbname, uid, pwd,'module.quality.check','check_quality',module)
detail_html = ''
detail_html = ''
html = '''<html><html><html><html><body><a name="TOP"></a>'''
html +="<h1> Module : %s </h1>"%(quality_result['name'])
html += "<h2> Final score : %s</h2>"%(quality_result['final_score'])
@@ -121,10 +121,11 @@ def check_quality(uri, user, pwd, dbname, modules):
html += "<ul>"
for x,y,detail in quality_result['check_detail_ids']:
test = detail.get('name')
msg = detail.get('message','')
score = round(float(detail.get('score',0)),2)
html += "<li><a href=\"#%s\">%s</a></li>"%(test.replace(' ','-'),test)
detail_html +="<div id=\"%s\"><h3>%s (Score : %s)</h3>%s</div>"%(test.replace(' ','-'),test,score,detail.get('detail'))
test_detail[test] = (score,detail.get('detail',''))
test_detail[test] = (score,msg,detail.get('detail',''))
html += "</ul>%s</body></html></html></html></html></html>"%(detail_html)
html += "</div>"
final[quality_result['name']] = (quality_result['final_score'],html,test_detail)
@@ -179,7 +180,7 @@ def create_db(uri, dbname, user='admin', pwd='admin', lang='en_US'):
elif res['type']=='state':
state = res['state']
res = execute(wiz_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
install_module(uri, dbname, ['base_module_quality'],user,pwd)
install_module(uri, dbname, ['base_module_quality'],user=user,pwd=pwd)
return True
def drop_db(uri, dbname):
@@ -189,12 +190,37 @@ def drop_db(uri, dbname):
execute(conn, 'drop', admin_passwd, dbname)
return True
def install_module(uri, dbname, modules, user='admin', pwd='admin'):
def make_links(uri, uid, dbname, source, destination, module, user, pwd):
if module in ('base','quality_integration_server'):
return True
if not os.path.islink(destination + module):
if not os.path.isdir(destination + module):
for path in source:
if os.path.isdir(path + '/' + module):
os.symlink(path + '/' + module, destination + '/' + module)
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'update_list')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','=',module)])
if len(module_ids):
data = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'read', module_ids[0],['name','dependencies_id'])
dep_datas = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module.dependency', 'read', data['dependencies_id'],['name'])
for dep_data in dep_datas:
make_links(uri, uid, dbname, source, destination, dep_data['name'], user, pwd)
return True
return False
def install_module(uri, dbname, modules, addons='', extra_addons='', user='admin', pwd='admin'):
uid = login(uri, dbname, user, pwd)
if extra_addons:
extra_addons = extra_addons.split(',')
if uid:
if addons and extra_addons:
for module in modules:
make_links(uri, uid, dbname, extra_addons, addons, module, user, pwd)
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
wizard_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_install', module_ids)
wiz_id = execute(wizard_conn, 'create', dbname, uid, pwd, 'module.upgrade.simple')
state = 'init'
@@ -254,6 +280,9 @@ parser.add_option("--login", dest="login", help="specify the User Login")
parser.add_option("--password", dest="pwd", help="specify the User Password")
parser.add_option("--translate-in", dest="translate_in",
help="specify .po files to import translation terms")
parser.add_option("--extra-addons", dest="extra_addons",
help="specify extra_addons and trunkCommunity modules path ")
(opt, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
@@ -281,6 +310,7 @@ options = {
'modules' : opt.modules or [],
'login' : opt.login or 'admin',
'pwd' : opt.pwd or '',
'extra-addons':opt.extra_addons or []
}
options['modules'] = opt.modules and map(lambda m: m.strip(), opt.modules.split(',')) or []
@@ -296,7 +326,7 @@ try:
if command == 'drop-db':
drop_db(uri, options['database'])
if command == 'install-module':
install_module(uri, options['database'], options['modules'], options['login'], options['pwd'])
install_module(uri, options['database'], options['modules'],options['addons-path'],options['extra-addons'],options['login'], options['pwd'])
if command == 'upgrade-module':
upgrade_module(uri, options['database'], options['modules'], options['login'], options['pwd'])
if command == 'check-quality':
+3 -2
View File
@@ -2469,9 +2469,10 @@ class orm(orm_template):
if c[0].startswith('default_'):
del rel_context[c[0]]
result = []
for field in upd_todo:
for id in ids:
self._columns[field].set(cr, self, id, field, vals[field], user, context=rel_context)
result += self._columns[field].set(cr, self, id, field, vals[field], user, context=rel_context) or []
for table in self._inherits:
col = self._inherits[table]
@@ -2533,7 +2534,7 @@ class orm(orm_template):
cr.execute('update '+self._table+' set parent_right=parent_right+%s where parent_right>=%s', (distance, position))
cr.execute('update '+self._table+' set parent_left=parent_left-%s, parent_right=parent_right-%s where parent_left>=%s and parent_left<%s', (pleft-position+distance,pleft-position+distance, pleft+distance, pright+distance))
result = self._store_get_values(cr, user, ids, vals.keys(), context)
result += self._store_get_values(cr, user, ids, vals.keys(), context)
for order, object, ids, fields in result:
self.pool.get(object)._store_set_values(cr, user, ids, fields, context)
+4 -1
View File
@@ -51,7 +51,10 @@ class report_printscreen_list(report_int):
return result
def _parse_string(self, view):
dom = etree.XML(view)
try:
dom = etree.XML(view.encode('utf-8'))
except:
dom = etree.XML(view)
return self._parse_node(dom)
def create(self, cr, uid, ids, datas, context=None):