Here is a simple Python script to trigger an ir.cron job from the command-line system.
I created this to let my customer use his proprietary job scheduler to trigger OpenERP tasks. It was tested on OpenERP 6.1.
1#!/usr/bin/python
23
import sys
4import traceback
5import xmlrpclib
6from optparse import OptionParser
7from datetime.datetime import now
89
parser = OptionParser()
10parser.add_option("-d", "--db", dest="db_name", help="OpenERP database name", metavar="DB_NAME", default="openerp")
11parser.add_option("-p", "--password", dest="password", help="OpenERP admin password", metavar="ADMIN_PASSWORD", default="admin")
12parser.add_option("-n", "--name", dest="cron_name", help="OpenERP ir.cron object name", metavar="CRON_NAME")
1314
(options, args) = parser.parse_args()
1516
assert options.cron_name
1718
# Query helpers
19sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
20q = lambda * a: sock.execute(options.db_name, 1, options.password, *a)
2122
try:
23ir_cron_ids = q('ir.cron', 'search', [('name', '=', options.cron_name)])
24if not ir_cron_ids:
25raise "No cron found in OpenERP."
26for ir_cron in q('ir.cron', 'read', ir_cron_ids, ['model', 'function', 'args']):
27print "%s, %s - (%s) %s %s%s" % (options.db_name, now().strftime('%Y-%m-%d %H:%M:%S'), ir_cron['id'], ir_cron['model'], ir_cron['function'], ir_cron['args'])
28q(ir_cron['model'], ir_cron['function'], *eval('tuple(%s)' % (ir_cron['args'] or '')))
29except:
30traceback.print_exc(file=sys.stdout)
31sys.exit(8)
3233
sys.exit()