This commit is contained in:
Bertrand Chenal committed 2008-01-18 01:45:33 +01:00
commit a489bd2be9
36 files changed
+154 -103

No files matched your search

+3 -1
View File
@@ -1,4 +1,6 @@
syntax: glob
.hgignore
*.pyc
*~
*~
addons/*
trytond.conf
+4 -4
View File
@@ -50,7 +50,7 @@ class ConfigManager(object):
parser.add_option("-c", "--config", dest="config",
help="specify alternate config file")
parser.add_option("-s", "--save", action="store_true", dest="save",
default=False, help="save configuration to ~/.terp_serverrc")
default=False, help="save configuration to ~/.trytondrc")
parser.add_option("-v", "--verbose", action="store_true",
dest="verbose", default=False, help="enable debugging")
parser.add_option("--pidfile", dest="pidfile",
@@ -125,12 +125,12 @@ class ConfigManager(object):
# or even to start the server...
if os.name == 'nt':
rcfilepath = os.path.join(os.path.abspath(
os.path.dirname(sys.argv[0])), 'tinyerp-server.conf')
os.path.dirname(sys.argv[0])), 'tryton-server.conf')
else:
rcfilepath = os.path.expanduser('~/.terp_serverrc')
rcfilepath = os.path.expanduser('~/.trytondrc')
self.rcfile = fname or opt.config \
or os.environ.get('TERP_SERVER') or rcfilepath
or os.environ.get('TRYTOND') or rcfilepath
self.load()
# Verify that we want to log or not, if not the output will go to stdout
+2 -2
View File
@@ -41,7 +41,7 @@ CREATE TABLE ir_model (
CREATE TABLE ir_model_fields (
id serial,
model varchar(64) DEFAULT ''::varchar NOT NULL,
model_id int references ir_model,
model_id int references ir_model on delete cascade,
name varchar(64) DEFAULT ''::varchar NOT NULL,
relation varchar(64),
field_description varchar(256),
@@ -172,7 +172,7 @@ create table wkf_transition
create table wkf_instance
(
id serial,
wkf_id int references wkf on delete set null,
wkf_id int references wkf on delete restrict,
uid int default null,
res_id int not null,
res_type varchar(64) not null,
File renamed without changes.
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="Actions" id="menu_action" parent_id="ir.menu_ir"/>
<record model="ir.ui.view" id="action_view_form">
@@ -245,4 +245,4 @@
<menuitem parent_id="menu_action"
action="act_action_wizard_form" id="menu_action_wizard"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="attachment_view_form">
<field name="model">ir.attachment</field>
@@ -53,4 +53,4 @@
<menuitem name="Attachments" parent_id="ir.menu_ir"
action="act_attachment_form" id="menu_attachment_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="cron_view_tree">
<field name="model">ir.cron</field>
@@ -63,4 +63,4 @@
<menuitem parent_id="ir.menu_ir"
action="act_cron_form" id="menu_cron_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="exports_view_form">
<field name="model">ir.exports</field>
@@ -47,4 +47,4 @@
<menuitem parent_id="ir.menu_ir"
action="act_exports_form" id="menu_exports_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="Administration" id="menu_administration"/>
<menuitem name="IR" id="menu_ir" parent_id="menu_administration"/>
</data>
</terp>
</tryton>
+1 -1
View File
@@ -32,7 +32,7 @@ class ModelFields(OSV):
'model': fields.char('Model Name', size=64, required=True),
'relation': fields.char('Model Relation', size=64),
'model_id': fields.many2one('ir.model', 'Model id', required=True,
select=True),
select=True, ondelete='cascade'),
'field_description': fields.char('Field Description', size=256),
'ttype': fields.char('Field Type', size=64),
'relate': fields.boolean('Click and Relate'),
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="model_view_form">
<field name="model">ir.model</field>
@@ -153,4 +153,4 @@
action="act_model_access_form" id="menu_model_access_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="category_view_form">
<field name="model">ir.module.category</field>
@@ -41,4 +41,4 @@
<menuitem parent_id="menu_modules"
action="act_category_tree" id="menu_category_tree"/>
</data>
</terp>
</tryton>
+32 -32
View File
@@ -128,10 +128,10 @@ class Module(OSV):
@staticmethod
def get_module_info(name):
"Return the content of the __terp__.py"
"Return the content of the __tryton__.py"
try:
file_p = tools.file_open(os.path.join(ADDONS_PATH, name,
'__terp__.py'))
'__tryton__.py'))
data = file_p.read()
info = eval(data)
file_p.close()
@@ -320,36 +320,36 @@ class Module(OSV):
if ids:
module_id = ids[0]
mod = self.browse(cursor, user, module_id)
terp = Module.get_module_info(mod_name)
if terp.get('installable', True) \
tryton = Module.get_module_info(mod_name)
if tryton.get('installable', True) \
and mod.state == 'uninstallable':
self.write(cursor, user, module_id, {
'state': 'uninstalled'}, context=context)
if vercmp(terp.get('version', ''),
if vercmp(tryton.get('version', ''),
mod.latest_version or '0') > 0:
self.write(cursor, user, module_id, {
'latest_version': terp.get('version'),
'latest_version': tryton.get('version'),
'url': '',
}, context=context)
res[0] += 1
self.write(cursor, user, module_id, {
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', ''),
'website': terp.get('website', ''),
'license': terp.get('license', 'GPL-2'),
'description': tryton.get('description', ''),
'shortdesc': tryton.get('name', ''),
'author': tryton.get('author', ''),
'website': tryton.get('website', ''),
'license': tryton.get('license', 'GPL-2'),
})
self._update_dependencies(cursor, user, module_id,
terp.get('depends', []))
tryton.get('depends', []))
self._update_category(cursor, user, module_id,
terp.get('category', 'None'))
tryton.get('category', 'None'))
continue
mod_path = os.path.join(ADDONS_PATH, name)
if os.path.isdir(mod_path) \
or os.path.islink(mod_path) \
or zipfile.is_zipfile(mod_path):
terp = Module.get_module_info(mod_name)
if not terp or not terp.get('installable', True):
tryton = Module.get_module_info(mod_name)
if not tryton or not tryton.get('installable', True):
continue
if not os.path.isfile(
os.path.join(ADDONS_PATH, mod_name+'.zip')):
@@ -364,18 +364,18 @@ class Module(OSV):
new_id = self.create(cursor, user, {
'name': mod_name,
'state': 'uninstalled',
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'website': terp.get('website', ''),
'latest_version': terp.get('version', ''),
'license': terp.get('license', 'GPL-2'),
'description': tryton.get('description', ''),
'shortdesc': tryton.get('name', ''),
'author': tryton.get('author', 'Unknown'),
'website': tryton.get('website', ''),
'latest_version': tryton.get('version', ''),
'license': tryton.get('license', 'GPL-2'),
})
res[1] += 1
self._update_dependencies(cursor, user, new_id,
terp.get('depends', []))
tryton.get('depends', []))
self._update_category(cursor, user, new_id,
terp.get('category', 'None'))
tryton.get('category', 'None'))
import socket
socket.setdefaulttimeout(10)
@@ -448,17 +448,17 @@ class Module(OSV):
except IOError:
raise ExceptORM('Error', 'Can not create the module file: %s'
% (fname,))
terp = Module.get_module_info(mod.name)
tryton = Module.get_module_info(mod.name)
self.write(cursor, user, mod.id, {
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'website': terp.get('website', ''),
'license': terp.get('license', 'GPL-2'),
'description': tryton.get('description', ''),
'shortdesc': tryton.get('name', ''),
'author': tryton.get('author', 'Unknown'),
'website': tryton.get('website', ''),
'license': tryton.get('license', 'GPL-2'),
})
self._update_dependencies(cursor, user, mod.id, terp.get('depends',
self._update_dependencies(cursor, user, mod.id, tryton.get('depends',
[]))
self._update_category(cursor, user, mod.id, terp.get('category',
self._update_category(cursor, user, mod.id, tryton.get('category',
'Uncategorized'))
return res
@@ -524,7 +524,7 @@ class ModuleDependency(OSV):
_columns = {
'name': fields.char('Name', size=128),
'module_id': fields.many2one('ir.module.module', 'Module', select=1),
'module_id': fields.many2one('ir.module.module', 'Module', select=1, ondelete='cascade'),
'state': fields.function(_state, method=True, type='selection',
selection=[
('uninstallable','Uninstallable'),
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="Modules" parent_id="menu_ir" id="menu_modules"/>
<record model="ir.ui.view" id="module_view_form">
@@ -187,4 +187,4 @@
type="wizard"
id="menu_module_install_upgrade"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="repository_view_form">
<field name="model">ir.module.repository</field>
@@ -51,4 +51,4 @@
<menuitem parent_id="menu_modules"
action="act_repository_form" id="menu_repository_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="property_view_form">
<field name="model">ir.property</field>
@@ -72,4 +72,4 @@
<menuitem parent_id="ir.menu_ir"
action="act_property_form" id="menu_property_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="rule_group_view_form">
<field name="model">ir.rule.group</field>
@@ -82,4 +82,4 @@
</field>
</record>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="Sequences" parent_id="ir.menu_ir" id="menu_sequence"/>
<record model="ir.ui.view" id="sequence_view_form">
@@ -106,4 +106,4 @@
<menuitem parent_id="menu_sequence"
action="act_sequence_type_form" id="menu_ir_sequence_type"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="translation_view_form">
<field name="model">ir.translation</field>
@@ -52,4 +52,4 @@
<menuitem name="Translations" parent_id="ir.menu_ir"
action="act_translation_form" id="menu_translation_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="menu_view_tree_tree">
<field name="model">ir.ui.menu</field>
@@ -75,4 +75,4 @@
<menuitem parent_id="menu_ui"
action="act_menu_form" id="menu_menu_form"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="UI" parent_id="menu_ir" id="menu_ui"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="view_view_form">
<field name="model">ir.ui.view</field>
@@ -95,4 +95,4 @@
<menuitem parent_id="menu_ui"
action="act_view_sc_form" id="menu_view_sc"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="values_view_form">
<field name="model">ir.values</field>
@@ -56,4 +56,4 @@
<menuitem parent_id="ir.menu_ir"
action="act_values_form" id="menu_values_form"/>
</data>
</terp>
</tryton>
+5 -5
View File
@@ -106,18 +106,18 @@ def create_graph(module_list, force=None):
for module in module_list:
if module[-4:] == '.zip':
module = module[:-4]
terp_file = OPJ(ADDONS_PATH, module, '__terp__.py')
tryton_file = OPJ(ADDONS_PATH, module, '__tryton__.py')
mod_path = OPJ(ADDONS_PATH, module)
if module in ('ir', 'workflow', 'res'):
root_path = os.path.dirname(__file__)
terp_file = OPJ(root_path, module, '__terp__.py')
tryton_file = OPJ(root_path, module, '__tryton__.py')
mod_path = OPJ(root_path, module)
if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'):
if os.path.isfile(tryton_file) or zipfile.is_zipfile(mod_path+'.zip'):
try:
info = eval(tools.file_open(terp_file).read())
info = eval(tools.file_open(tryton_file).read())
except:
Logger().notify_channel('init', LOG_ERROR,
'addon:%s:eval file %s' % (module, terp_file))
'addon:%s:eval file %s' % (module, tryton_file))
raise
if info.get('installable', True):
packages.append((module, info.get('depends', []), info))
+52 -3
View File
@@ -584,6 +584,55 @@ class ORM(object):
cursor.execute("DROP INDEX \"%s_%s_index\"" % \
(self._table, k))
cursor.commit()
if isinstance(field, fields.many2one):
ref_obj = self.pool.get(field._obj)
if ref_obj:
ref = ref_obj._table
else:
ref = field._obj.replace('.', '_')
if ref != 'ir_actions':
cursor.execute('SELECT confdeltype, conname ' \
'FROM pg_constraint as con, ' \
'pg_class as cl1, pg_class as cl2, ' \
'pg_attribute as att1, pg_attribute as att2 ' \
'WHERE con.conrelid = cl1.oid ' \
'AND cl1.relname = %s ' \
'AND con.confrelid = cl2.oid ' \
'AND cl2.relname = %s ' \
'AND array_lower(con.conkey, 1) = 1 ' \
'AND con.conkey[1] = att1.attnum ' \
'AND att1.attrelid = cl1.oid ' \
'AND att1.attname = %s ' \
'AND array_lower(con.confkey, 1) = 1 ' \
'AND con.confkey[1] = att2.attnum ' \
'AND att2.attrelid = cl2.oid ' \
'AND att2.attname = %s ' \
'AND con.contype = \'f\'',
(self._table, ref, k, 'id'))
res = cursor.dictfetchall()
if res:
confdeltype = {
'RESTRICT': 'r',
'NO ACTION': 'a',
'CASCADE': 'c',
'SET NULL': 'n',
'SET DEFAULT': 'd',
}
if res[0]['confdeltype'] != \
confdeltype.get(
field.ondelete.upper(),
'a'):
cursor.execute('ALTER TABLE "' + \
self._table + '" ' \
'DROP CONSTRAINT "' + \
res[0]['conname'] + '"')
cursor.execute('ALTER TABLE "' + \
self._table + '" ' \
'ADD FOREIGN KEY ' \
'("' + k + '") ' \
'REFERENCES "' + ref + \
'" ON DELETE ' + field.ondelete)
cursor.commit()
else:
# TODO add error message
logger.notify_channel('init', LOG_ERROR, '')
@@ -1562,7 +1611,7 @@ class ORM(object):
result = self.view_header_get(cursor, user, False, node.localName,
context)
if result:
node.setAttribute('string', result)
node.setAttribute('string', result.decode('utf8'))
if node.nodeType == node.ELEMENT_NODE:
# translate view
@@ -1594,13 +1643,13 @@ class ORM(object):
for fname, gname in cursor.fetchall():
if oldgroup != gname:
child = doc.createElement('separator')
child.setAttribute('string', gname)
child.setAttribute('string', gname.decode('utf8'))
child.setAttribute('colspan', "4")
oldgroup = gname
parent.insertBefore(child, node)
child = doc.createElement('field')
child.setAttribute('name', fname)
child.setAttribute('name', fname.decode('utf8'))
parent.insertBefore(child, node)
parent.removeChild(node)
File renamed without changes.
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="res.lang" id="lang_en">
<field name="code">en_US</field>
@@ -35,4 +35,4 @@
<menuitem parent_id="res.menu_res"
action="act_lang_form" id="menu_lang_form"/>
</data>
</terp>
</tryton>
Binary file not shown.
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="ir.ui.view" id="request_view_tree">
<field name="model">res.request</field>
@@ -136,4 +136,4 @@
</field>
</record>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="Res" id="menu_res" parent_id="ir.menu_administration"/>
</data>
</terp>
</tryton>
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<record model="res.group" id="group_admin">
<field name="name">admin</field>
@@ -186,4 +186,4 @@
<menuitem parent_id="res.menu_res"
action="act_role_tree" id="menu_role_tree"/>
</data>
</terp>
</tryton>
+5 -5
View File
@@ -116,20 +116,20 @@ def init_db(cursor):
addons_path = os.path.join(os.path.dirname(__file__), 'addons')
for i in (os.listdir(addons_path) + ['ir', 'workflow', 'res']):
terp_file = opj(addons_path, i, '__terp__.py')
tryton_file = opj(addons_path, i, '__tryton__.py')
mod_path = opj(addons_path, i)
if i in ('ir', 'workflow', 'res'):
root_path = os.path.dirname(__file__)
terp_file = opj(root_path, i, '__terp__.py')
tryton_file = opj(root_path, i, '__tryton__.py')
mod_path = opj(root_path, i)
info = {}
if os.path.isfile(terp_file) \
if os.path.isfile(tryton_file) \
and not os.path.isfile(opj(addons_path, i + '.zip')):
info = eval(file(terp_file).read())
info = eval(file(tryton_file).read())
elif zipfile.is_zipfile(mod_path):
zfile = zipfile.ZipFile(mod_path)
i = os.path.splitext(i)[0]
info = eval(zfile.read(opj(i, '__terp__.py')))
info = eval(zfile.read(opj(i, '__tryton__.py')))
if info:
categs = info.get('category', 'Uncategorized').split('/')
p_id = None
+2 -2
View File
@@ -274,7 +274,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
self.taghandler = None
# Managed tags are handled by the current class
self.managedtags= ["data", "terp"]
self.managedtags= ["data", "tryton"]
self.idlist = []
@@ -301,7 +301,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
elif name == "data":
self.noupdate = attributes.get("noupdate", False)
elif name == "terp":
elif name == "tryton":
pass
else:
File renamed without changes.
+4 -4
View File
@@ -44,7 +44,7 @@ class WorkflowActivity(OSV):
_columns = {
'name': fields.char('Name', size=64, required=True),
'wkf_id': fields.many2one('workflow', 'Workflow', required=True,
select=1),
select=1, ondelete='cascade'),
'split_mode': fields.selection([
('XOR', 'Xor'),
('OR', 'Or'),
@@ -93,9 +93,9 @@ class WorkflowTransition(OSV):
'role_id': fields.many2one('res.role', 'Role Required'),
'condition': fields.char('Condition', required=True, size=128),
'act_from': fields.many2one('workflow.activity', 'Source Activity',
required=True, select=1),
required=True, select=1, ondelete='cascade'),
'act_to': fields.many2one('workflow.activity', 'Destination Activity',
required=True, select=1),
required=True, select=1, ondelete='cascade'),
}
_defaults = {
'condition': lambda *a: 'True',
@@ -112,7 +112,7 @@ class WorkflowInstance(OSV):
_log_access = False
_description = __doc__
_columns = {
'wkf_id': fields.many2one('workflow', 'Workflow', ondelete="cascade"),
'wkf_id': fields.many2one('workflow', 'Workflow', ondelete="restrict"),
'uid': fields.integer('User ID'),
'res_id': fields.integer('Resource ID'),
'res_type': fields.char('Resource Model', size=64),
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<terp>
<tryton>
<data>
<menuitem name="Workflow" id="menu_workflow" parent_id="ir.menu_administration"/>
<record model="ir.ui.view" id="workflow_view_form">
@@ -271,4 +271,4 @@
<menuitem parent_id="menu_workflow"
action="act_workitem_form" id="menu_workitem_form"/>
</data>
</terp>
</tryton>