[MERGE]:Merged from trunk
bzr revid: apa@tinyerp.com-20100908133432-0poxyin1wrkkvsdp bzr revid: apa@tinyerp.com-20100909044341-k8u7z6kxp1s89h0u
This commit is contained in:
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.4\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 09:38+0000\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:24+0000\n"
|
||||
"Last-Translator: nafterburner <nafterburner@gmail.com>\n"
|
||||
"Language-Team: openerp-translators\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:39+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
"Language: hr\n"
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.4\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 09:29+0000\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:21+0000\n"
|
||||
"Last-Translator: OpenERP Administrators <Unknown>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:39+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: base
|
||||
|
||||
@@ -8,13 +8,13 @@ msgstr ""
|
||||
"Project-Id-Version: openobject-server\n"
|
||||
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 09:42+0000\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:27+0000\n"
|
||||
"Last-Translator: Harry (Open ERP) <hmo@tinyerp.com>\n"
|
||||
"Language-Team: Japanese <ja@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:39+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: base
|
||||
|
||||
@@ -8,13 +8,13 @@ msgstr ""
|
||||
"Project-Id-Version: openobject-addons\n"
|
||||
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 09:13+0000\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:18+0000\n"
|
||||
"Last-Translator: ub121 <ubs121@gmail.com>\n"
|
||||
"Language-Team: Mongolian <mn@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:39+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: base
|
||||
|
||||
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: pt_BR\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 10:38+0000\n"
|
||||
"Last-Translator: Luiz Fernando M.França <Unknown>\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:22+0000\n"
|
||||
"Last-Translator: OpenERP Administrators <Unknown>\n"
|
||||
"Language-Team: <pt@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:40+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: base
|
||||
|
||||
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.0\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 09:46+0000\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:28+0000\n"
|
||||
"Last-Translator: Anders Wallenquist <anders.wallenquist@vertel.se>\n"
|
||||
"Language-Team: <>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:39+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: base
|
||||
|
||||
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.0\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
|
||||
"PO-Revision-Date: 2010-09-06 09:33+0000\n"
|
||||
"PO-Revision-Date: 2010-09-07 07:23+0000\n"
|
||||
"Last-Translator: Fabien (Open ERP) <fp@tinyerp.com>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-07 04:48+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-09-08 04:39+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: base
|
||||
|
||||
@@ -132,11 +132,25 @@ class ir_translation(osv.osv):
|
||||
|
||||
@tools.cache(skiparg=3)
|
||||
def _get_source(self, cr, uid, name, tt, lang, source=None):
|
||||
"""
|
||||
Returns the translation for the given combination of name, type, language
|
||||
and source. All values passed to this method should be unicode (not byte strings),
|
||||
especially ``source``.
|
||||
|
||||
:param name: identification of the term to translate, such as field name
|
||||
:param type: type of term to translate (see ``type`` field on ir.translation)
|
||||
:param lang: language code of the desired translation
|
||||
:param source: optional source term to translate (should be unicode)
|
||||
:rtype: unicode
|
||||
:return: the request translation, or an empty unicode string if no translation was
|
||||
found and `source` was not passed
|
||||
"""
|
||||
# FIXME: should assert that `source` is unicode and fix all callers to always pass unicode
|
||||
# so we can remove the string encoding/decoding.
|
||||
|
||||
if not lang:
|
||||
return ''
|
||||
return u''
|
||||
if source:
|
||||
#if isinstance(source, unicode):
|
||||
# source = source.encode('utf8')
|
||||
cr.execute('select value ' \
|
||||
'from ir_translation ' \
|
||||
'where lang=%s ' \
|
||||
@@ -152,9 +166,9 @@ class ir_translation(osv.osv):
|
||||
'and name=%s',
|
||||
(lang or '', tt, tools.ustr(name)))
|
||||
res = cr.fetchone()
|
||||
trad = res and res[0] or ''
|
||||
trad = res and res[0] or u''
|
||||
if source and not trad:
|
||||
return source
|
||||
return tools.ustr(source)
|
||||
return trad
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
|
||||
@@ -305,7 +305,10 @@ class res_partner_address(osv.osv):
|
||||
if r['name'] and (r['city'] or r['country_id']):
|
||||
addr += ', '
|
||||
addr += (r['country_id'] and r['country_id'][1] or '') + ' ' + (r['city'] or '') + ' ' + (r['street'] or '')
|
||||
res.append((r['id'], addr.strip() or '/'))
|
||||
if context.get('contact_display', 'contact')=='partner_address':
|
||||
res.append((r['id'], r['partner_id'][1] +','+ addr.strip() or '/'))
|
||||
else:
|
||||
res.append((r['id'], addr.strip() or '/'))
|
||||
return res
|
||||
|
||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
||||
@@ -313,7 +316,7 @@ class res_partner_address(osv.osv):
|
||||
args=[]
|
||||
if not context:
|
||||
context={}
|
||||
if context.get('contact_display', 'contact')=='partner':
|
||||
if context.get('contact_display', 'contact')=='partner ' or context.get('contact_display', 'contact')=='partner_address ' :
|
||||
ids = self.search(cr, user, [('partner_id',operator,name)], limit=limit, context=context)
|
||||
else:
|
||||
if not name:
|
||||
|
||||
@@ -330,7 +330,7 @@ class res_config_installer(osv.osv_memory):
|
||||
|
||||
def _already_installed(self, cr, uid, context=None):
|
||||
""" For each module (boolean fields in a res.config.installer),
|
||||
check if it's already installed (neither uninstallable nor uninstalled)
|
||||
check if it's already installed (either 'to install', 'to upgrade' or 'installed')
|
||||
and if it is, check it by default
|
||||
"""
|
||||
modules = self.pool.get('ir.module.module')
|
||||
@@ -341,7 +341,7 @@ class res_config_installer(osv.osv_memory):
|
||||
cr, uid,
|
||||
modules.search(cr, uid,
|
||||
[('name','in',selectable),
|
||||
('state','not in',['uninstallable', 'uninstalled'])],
|
||||
('state','in',['to install', 'installed', 'to upgrade'])],
|
||||
context=context),
|
||||
context=context)
|
||||
|
||||
|
||||
+60
-45
@@ -1349,13 +1349,13 @@ class orm_template(object):
|
||||
# translate view
|
||||
if ('lang' in context) and not result:
|
||||
if node.get('string'):
|
||||
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('string').encode('utf8'))
|
||||
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('string'))
|
||||
if not trans and ('base_model_name' in context):
|
||||
trans = self.pool.get('ir.translation')._get_source(cr, user, context['base_model_name'], 'view', context['lang'], node.get('string').encode('utf8'))
|
||||
trans = self.pool.get('ir.translation')._get_source(cr, user, context['base_model_name'], 'view', context['lang'], node.get('string'))
|
||||
if trans:
|
||||
node.set('string', trans)
|
||||
if node.get('sum'):
|
||||
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('sum').encode('utf8'))
|
||||
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('sum'))
|
||||
if trans:
|
||||
node.set('sum', trans)
|
||||
|
||||
@@ -2169,7 +2169,8 @@ class orm(orm_template):
|
||||
_sql_constraints = []
|
||||
_table = None
|
||||
_protected = ['read', 'write', 'create', 'default_get', 'perm_read', 'unlink', 'fields_get', 'fields_view_get', 'search', 'name_get', 'distinct_field_get', 'name_search', 'copy', 'import_data', 'search_count', 'exists']
|
||||
|
||||
__logger = logging.getLogger('orm')
|
||||
__schema = logging.getLogger('orm.schema')
|
||||
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
|
||||
"""
|
||||
Get the list of records in list view grouped by the given ``groupby`` fields
|
||||
@@ -2371,7 +2372,6 @@ class orm(orm_template):
|
||||
cr.execute(update_query, (ss[1](val), key))
|
||||
|
||||
def _check_removed_columns(self, cr, log=False):
|
||||
logger = netsvc.Logger()
|
||||
# iterate on the database columns to drop the NOT NULL constraints
|
||||
# of fields which were required but have been removed (or will be added by another module)
|
||||
columns = [c for c in self._columns if not (isinstance(self._columns[c], fields.function) and not self._columns[c].store)]
|
||||
@@ -2386,14 +2386,15 @@ class orm(orm_template):
|
||||
|
||||
for column in cr.dictfetchall():
|
||||
if log:
|
||||
logger.notifyChannel("orm", netsvc.LOG_DEBUG, "column %s is in the table %s but not in the corresponding object %s" % (column['attname'], self._table, self._name))
|
||||
self.__logger.debug("column %s is in the table %s but not in the corresponding object %s",
|
||||
column['attname'], self._table, self._name)
|
||||
if column['attnotnull']:
|
||||
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" DROP NOT NULL' % (self._table, column['attname']))
|
||||
logging.getLogger('schema').info("Table '%s': column '%s': dropped NOT NULL constraint" % (self._table, column['attname']))
|
||||
self.__schema.debug("Table '%s': column '%s': dropped NOT NULL constraint",
|
||||
self._table, column['attname'])
|
||||
|
||||
def _auto_init(self, cr, context={}):
|
||||
store_compute = False
|
||||
logger = netsvc.Logger()
|
||||
create = False
|
||||
todo_end = []
|
||||
self._field_create(cr, context=context)
|
||||
@@ -2404,7 +2405,7 @@ class orm(orm_template):
|
||||
cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''")))
|
||||
create = True
|
||||
|
||||
logging.getLogger('schema').info("Table '%s': created" % (self._table, ))
|
||||
self.__schema.debug("Table '%s': created", self._table)
|
||||
|
||||
cr.commit()
|
||||
if self._parent_store:
|
||||
@@ -2416,13 +2417,18 @@ class orm(orm_template):
|
||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "parent_left" INTEGER' % (self._table,))
|
||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "parent_right" INTEGER' % (self._table,))
|
||||
if 'parent_left' not in self._columns:
|
||||
logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_left on object %s: fields.integer(\'Left Parent\', select=1)' % (self._table, ))
|
||||
logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, 'parent_left', 'INTEGER'))
|
||||
self.__logger.error('create a column parent_left on object %s: fields.integer(\'Left Parent\', select=1)',
|
||||
self._table)
|
||||
self.__schema.debug("Table '%s': added column '%s' with definition=%s",
|
||||
self._table, 'parent_left', 'INTEGER')
|
||||
if 'parent_right' not in self._columns:
|
||||
logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_right on object %s: fields.integer(\'Right Parent\', select=1)' % (self._table, ))
|
||||
logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, 'parent_right', 'INTEGER'))
|
||||
self.__logger.error('create a column parent_right on object %s: fields.integer(\'Right Parent\', select=1)',
|
||||
self._table)
|
||||
self.__schema.debug("Table '%s': added column '%s' with definition=%s",
|
||||
self._table, 'parent_right', 'INTEGER')
|
||||
if self._columns[self._parent_name].ondelete != 'cascade':
|
||||
logger.notifyChannel('orm', netsvc.LOG_ERROR, "The column %s on object %s must be set as ondelete='cascade'" % (self._parent_name, self._name))
|
||||
self.__logger.error("The column %s on object %s must be set as ondelete='cascade'",
|
||||
self._parent_name, self._name)
|
||||
|
||||
cr.commit()
|
||||
store_compute = True
|
||||
@@ -2443,7 +2449,8 @@ class orm(orm_template):
|
||||
if not cr.rowcount:
|
||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, logs[k]))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, k, logs[k]))
|
||||
self.__schema.debug("Table '%s': added column '%s' with definition=%s",
|
||||
self._table, k, logs[k])
|
||||
|
||||
self._check_removed_columns(cr, log=False)
|
||||
|
||||
@@ -2472,9 +2479,8 @@ class orm(orm_template):
|
||||
res = cr.fetchone()[0]
|
||||
if not res:
|
||||
cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY (%s) REFERENCES "%s" ON DELETE SET NULL' % (self._obj, f._fields_id, f._table))
|
||||
logging.getLogger('schema').info("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE SET NULL" % (
|
||||
self.__schema.debug("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE SET NULL",
|
||||
self._obj, f._fields_id, f._table)
|
||||
)
|
||||
elif isinstance(f, fields.many2many):
|
||||
cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (f._rel,))
|
||||
if not cr.dictfetchall():
|
||||
@@ -2487,7 +2493,8 @@ class orm(orm_template):
|
||||
cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id2, f._rel, f._id2))
|
||||
cr.execute("COMMENT ON TABLE \"%s\" IS 'RELATION BETWEEN %s AND %s'" % (f._rel, self._table, ref))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Create table '%s': relation between '%s' and '%s'" % (f._rel, self._table, ref))
|
||||
self.__schema.debug("Create table '%s': relation between '%s' and '%s'",
|
||||
f._rel, self._table, ref)
|
||||
else:
|
||||
cr.execute("SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size " \
|
||||
"FROM pg_class c,pg_attribute a,pg_type t " \
|
||||
@@ -2508,7 +2515,8 @@ class orm(orm_template):
|
||||
cr.execute('ALTER TABLE "%s" RENAME "%s" TO "%s"' % (self._table, f.oldname, k))
|
||||
res = res_old
|
||||
res[0]['attname'] = k
|
||||
logging.getLogger('schema').info("Table '%s': renamed column '%s' to '%s'" % (self._table, f.oldname, k))
|
||||
self.__schema.debug("Table '%s': renamed column '%s' to '%s'",
|
||||
self._table, f.oldname, k)
|
||||
|
||||
if len(res) == 1:
|
||||
f_pg_def = res[0]
|
||||
@@ -2517,10 +2525,12 @@ class orm(orm_template):
|
||||
f_pg_notnull = f_pg_def['attnotnull']
|
||||
if isinstance(f, fields.function) and not f.store and\
|
||||
not getattr(f, 'nodrop', False):
|
||||
logger.notifyChannel('orm', netsvc.LOG_INFO, 'column %s (%s) in table %s removed: converted to a function !\n' % (k, f.string, self._table))
|
||||
self.__logger.info('column %s (%s) in table %s removed: converted to a function !\n',
|
||||
k, f.string, self._table)
|
||||
cr.execute('ALTER TABLE "%s" DROP COLUMN "%s" CASCADE' % (self._table, k))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': dropped column '%s' with cascade" % (self._table, k))
|
||||
self.__schema.debug("Table '%s': dropped column '%s' with cascade",
|
||||
self._table, k)
|
||||
f_obj_type = None
|
||||
else:
|
||||
f_obj_type = get_pg_type(f) and get_pg_type(f)[0]
|
||||
@@ -2542,7 +2552,8 @@ class orm(orm_template):
|
||||
cr.execute('UPDATE "%s" SET "%s"=temp_change_size::VARCHAR(%d)' % (self._table, k, f.size))
|
||||
cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': column '%s' (type varchar) changed size from %s to %s" % (self._table, k, f_pg_size, f.size))
|
||||
self.__schema.debug("Table '%s': column '%s' (type varchar) changed size from %s to %s",
|
||||
self._table, k, f_pg_size, f.size)
|
||||
for c in casts:
|
||||
if (f_pg_type==c[0]) and (f._type==c[1]):
|
||||
if f_pg_type != f_obj_type:
|
||||
@@ -2552,7 +2563,8 @@ class orm(orm_template):
|
||||
cr.execute(('UPDATE "%s" SET "%s"=temp_change_size'+c[3]) % (self._table, k))
|
||||
cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': column '%s' changed type from %s to %s" % (self._table, k, c[0], c[1]))
|
||||
self.__schema.debug("Table '%s': column '%s' changed type from %s to %s",
|
||||
self._table, k, c[0], c[1])
|
||||
break
|
||||
|
||||
if f_pg_type != f_obj_type:
|
||||
@@ -2572,9 +2584,8 @@ class orm(orm_template):
|
||||
cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO "%s"' % (self._table, k, newname))
|
||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))
|
||||
cr.execute("COMMENT ON COLUMN %s.%s IS '%s'" % (self._table, k, f.string.replace("'", "''")))
|
||||
logging.getLogger('schema').info("Table '%s': column '%s' has changed type (DB=%s, def=%s), data moved to column %s !" % (
|
||||
self.__schema.debug("Table '%s': column '%s' has changed type (DB=%s, def=%s), data moved to column %s !",
|
||||
self._table, k, f_pg_type, f._type, newname)
|
||||
)
|
||||
|
||||
# if the field is required and hasn't got a NOT NULL constraint
|
||||
if f.required and f_pg_notnull == 0:
|
||||
@@ -2594,18 +2605,19 @@ class orm(orm_template):
|
||||
try:
|
||||
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': column '%s': added NOT NULL constraint" % (self._table, k))
|
||||
self.__schema.debug("Table '%s': column '%s': added NOT NULL constraint",
|
||||
self._table, k)
|
||||
except Exception:
|
||||
msg = "Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\
|
||||
"If you want to have it, you should update the records and execute manually:\n"\
|
||||
"ALTER TABLE %s ALTER COLUMN %s SET NOT NULL" % (
|
||||
self._table, k, self._table, k)
|
||||
logger.notifyChannel('schema', netsvc.LOG_WARNING, msg)
|
||||
"ALTER TABLE %s ALTER COLUMN %s SET NOT NULL"
|
||||
self.__schema.warn(msg, self._table, k, self._table, k)
|
||||
cr.commit()
|
||||
elif not f.required and f_pg_notnull == 1:
|
||||
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" DROP NOT NULL' % (self._table, k))
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': column '%s': dropped NOT NULL constraint" % (self._table, k))
|
||||
self.__schema.debug("Table '%s': column '%s': dropped NOT NULL constraint",
|
||||
self._table, k)
|
||||
# Verify index
|
||||
indexname = '%s_%s_index' % (self._table, k)
|
||||
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = %s and tablename = %s", (indexname, self._table))
|
||||
@@ -2618,13 +2630,13 @@ class orm(orm_template):
|
||||
msg = "Table '%s': Adding (b-tree) index for text column '%s'."\
|
||||
"This is probably useless (does not work for fulltext search) and prevents INSERTs of long texts"\
|
||||
" because there is a length limit for indexable btree values!\n"\
|
||||
"Use a search view instead if you simply want to make the field searchable." % (self._table, k, f._type)
|
||||
logger.notifyChannel('schema', netsvc.LOG_WARNING, msg)
|
||||
"Use a search view instead if you simply want to make the field searchable."
|
||||
self.__schema.warn(msg, self._table, k, f._type)
|
||||
if res2 and not f.select:
|
||||
cr.execute('DROP INDEX "%s_%s_index"' % (self._table, k))
|
||||
cr.commit()
|
||||
msg = "Table '%s': dropping index for column '%s' of type '%s' as it is not required anymore" % (self._table, k, f._type)
|
||||
logger.notifyChannel('schema', netsvc.LOG_WARNING, msg)
|
||||
msg = "Table '%s': dropping index for column '%s' of type '%s' as it is not required anymore"
|
||||
self.__schema.warn(msg, self._table, k, f._type)
|
||||
|
||||
if isinstance(f, fields.many2one):
|
||||
ref = self.pool.get(f._obj)._table
|
||||
@@ -2650,15 +2662,17 @@ class orm(orm_template):
|
||||
cr.execute('ALTER TABLE "' + self._table + '" DROP CONSTRAINT "' + res2[0]['conname'] + '"')
|
||||
cr.execute('ALTER TABLE "' + self._table + '" ADD FOREIGN KEY ("' + k + '") REFERENCES "' + ref + '" ON DELETE ' + f.ondelete)
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info("Table '%s': column '%s': XXX" % (self._table, k))
|
||||
self.__schema.debug("Table '%s': column '%s': XXX",
|
||||
self._table, k)
|
||||
elif len(res) > 1:
|
||||
logger.notifyChannel('orm', netsvc.LOG_ERROR, "Programming error, column %s->%s has multiple instances !" % (self._table, k))
|
||||
netsvc.Logger().notifyChannel('orm', netsvc.LOG_ERROR, "Programming error, column %s->%s has multiple instances !" % (self._table, k))
|
||||
if not res:
|
||||
if not isinstance(f, fields.function) or f.store:
|
||||
# add the missing field
|
||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))
|
||||
cr.execute("COMMENT ON COLUMN %s.%s IS '%s'" % (self._table, k, f.string.replace("'", "''")))
|
||||
logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, k, get_pg_type(f)[1]))
|
||||
self.__schema.debug("Table '%s': added column '%s' with definition=%s",
|
||||
self._table, k, get_pg_type(f)[1])
|
||||
|
||||
# initialize it
|
||||
if not create and k in self._defaults:
|
||||
@@ -2671,7 +2685,7 @@ class orm(orm_template):
|
||||
query = 'UPDATE "%s" SET "%s"=%s' % (self._table, k, ss[0])
|
||||
cr.execute(query, (ss[1](default),))
|
||||
cr.commit()
|
||||
logger.notifyChannel('data', netsvc.LOG_DEBUG, "Table '%s': setting default value of new column %s" % (self._table, k))
|
||||
netsvc.Logger().notifyChannel('data', netsvc.LOG_DEBUG, "Table '%s': setting default value of new column %s" % (self._table, k))
|
||||
|
||||
if isinstance(f, fields.function):
|
||||
order = 10
|
||||
@@ -2688,21 +2702,22 @@ class orm(orm_template):
|
||||
# ir_actions is inherited so foreign key doesn't work on it
|
||||
if ref != 'ir_actions':
|
||||
cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY ("%s") REFERENCES "%s" ON DELETE %s' % (self._table, k, ref, f.ondelete))
|
||||
logging.getLogger('schema').info("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE %s" % (
|
||||
self._table, k, ref, f.ondelete))
|
||||
self.__schema.debug("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE %s",
|
||||
self._table, k, ref, f.ondelete)
|
||||
if f.select:
|
||||
cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (self._table, k, self._table, k))
|
||||
if f.required:
|
||||
try:
|
||||
cr.commit()
|
||||
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
|
||||
logging.getLogger('schema').info("Table '%s': column '%s': added a NOT NULL constraint" % (self._table, k))
|
||||
self.__schema.debug("Table '%s': column '%s': added a NOT NULL constraint",
|
||||
self._table, k)
|
||||
except Exception:
|
||||
msg = "WARNING: unable to set column %s of table %s not null !\n"\
|
||||
"Try to re-run: openerp-server.py --update=module\n"\
|
||||
"If it doesn't work, update records and execute manually:\n"\
|
||||
"ALTER TABLE %s ALTER COLUMN %s SET NOT NULL" % (k, self._table, self._table, k)
|
||||
logger.notifyChannel('orm', netsvc.LOG_WARNING, msg)
|
||||
"ALTER TABLE %s ALTER COLUMN %s SET NOT NULL"
|
||||
self.__logger.warn(msg, k, self._table, self._table, k)
|
||||
cr.commit()
|
||||
for order, f, k in todo_update_store:
|
||||
todo_end.append((order, self._update_store, (f, k)))
|
||||
@@ -2756,9 +2771,9 @@ class orm(orm_template):
|
||||
try:
|
||||
cr.execute(sql_action['query'])
|
||||
cr.commit()
|
||||
logging.getLogger('schema').info(sql_action['msg_ok'])
|
||||
self.__schema.debug(sql_action['msg_ok'])
|
||||
except:
|
||||
logger.notifyChannel('schema', netsvc.LOG_WARNING, sql_action['msg_err'])
|
||||
self.__schema.warn(sql_action['msg_err'])
|
||||
cr.rollback()
|
||||
|
||||
if create:
|
||||
|
||||
+21
-19
@@ -68,7 +68,7 @@ class configmanager(object):
|
||||
'import_partial': "",
|
||||
'pidfile': None,
|
||||
'logfile': None,
|
||||
'logrotate': '1',
|
||||
'logrotate': True,
|
||||
'smtp_server': 'localhost',
|
||||
'smtp_user': False,
|
||||
'smtp_port':25,
|
||||
@@ -88,6 +88,8 @@ class configmanager(object):
|
||||
'static_http_enable': False,
|
||||
'static_http_document_root': None,
|
||||
'static_http_url_prefix': None,
|
||||
'secure_cert_file': 'server.cert',
|
||||
'secure_pkey_file': 'server.pkey',
|
||||
}
|
||||
|
||||
self.misc = {}
|
||||
@@ -119,8 +121,8 @@ class configmanager(object):
|
||||
group.add_option("--xmlrpcs-interface", dest="xmlrpcs_interface", help="specify the TCP IP address for the XML-RPC Secure protocol")
|
||||
group.add_option("--xmlrpcs-port", dest="xmlrpcs_port", help="specify the TCP port for the XML-RPC Secure protocol", type="int")
|
||||
group.add_option("--no-xmlrpcs", dest="xmlrpcs", action="store_false", help="disable the XML-RPC Secure protocol")
|
||||
group.add_option("--cert-file", dest="secure_cert_file", default="server.cert", help="specify the certificate file for the SSL connection")
|
||||
group.add_option("--pkey-file", dest="secure_pkey_file", default="server.pkey", help="specify the private key file for the SSL connection")
|
||||
group.add_option("--cert-file", dest="secure_cert_file", help="specify the certificate file for the SSL connection")
|
||||
group.add_option("--pkey-file", dest="secure_pkey_file", help="specify the private key file for the SSL connection")
|
||||
parser.add_option_group(group)
|
||||
|
||||
# NET-RPC
|
||||
@@ -129,21 +131,21 @@ class configmanager(object):
|
||||
group.add_option("--netrpc-port", dest="netrpc_port", help="specify the TCP port for the NETRPC protocol", type="int")
|
||||
group.add_option("--no-netrpc", dest="netrpc", action="store_false", help="disable the NETRPC protocol")
|
||||
parser.add_option_group(group)
|
||||
|
||||
|
||||
# Static HTTP
|
||||
group = optparse.OptionGroup(parser, "Static HTTP service")
|
||||
group.add_option("--static-http-enable", dest="static_http_enable", action="store_true", default=False, help="enable static HTTP service for serving plain HTML files")
|
||||
group.add_option("--static-http-document-root", dest="static_http_document_root", help="specify the directory containing your static HTML files (e.g '/var/www/')")
|
||||
group.add_option("--static-http-url-prefix", dest="static_http_url_prefix", help="specify the URL root prefix where you want web browsers to access your static HTML files (e.g '/')")
|
||||
parser.add_option_group(group)
|
||||
|
||||
|
||||
parser.add_option("-i", "--init", dest="init", help="init a module (use \"all\" for all modules)")
|
||||
parser.add_option("--without-demo", dest="without_demo",
|
||||
help="load demo data for a module (use \"all\" for all modules)", default=False)
|
||||
parser.add_option("-u", "--update", dest="update",
|
||||
help="update a module (use \"all\" for all modules)")
|
||||
parser.add_option("--cache-timeout", dest="cache_timeout",
|
||||
help="set the timeout for the cache system", default=100000, type="int")
|
||||
help="set the timeout for the cache system", type="int")
|
||||
parser.add_option("-t", "--timezone", dest="timezone", help="specify reference timezone for the server (e.g. Europe/Brussels")
|
||||
|
||||
# stops the server from launching after initialization
|
||||
@@ -166,7 +168,7 @@ class configmanager(object):
|
||||
group = optparse.OptionGroup(parser, "Logging Configuration")
|
||||
group.add_option("--logfile", dest="logfile", help="file where the server log will be stored")
|
||||
group.add_option("--no-logrotate", dest="logrotate", action="store_false",
|
||||
default=None, help="do not rotate the logfile")
|
||||
help="do not rotate the logfile")
|
||||
group.add_option("--syslog", action="store_true", dest="syslog",
|
||||
default=False, help="Send the log to the syslog server")
|
||||
group.add_option('--log-level', dest='log_level', type='choice', choices=self._LOGLEVELS.keys(),
|
||||
@@ -175,12 +177,12 @@ class configmanager(object):
|
||||
|
||||
# SMTP Group
|
||||
group = optparse.OptionGroup(parser, "SMTP Configuration")
|
||||
group.add_option('--email-from', dest='email_from', default='', help='specify the SMTP email address for sending email')
|
||||
group.add_option('--smtp', dest='smtp_server', default='', help='specify the SMTP server for sending email')
|
||||
group.add_option('--smtp-port', dest='smtp_port', default='25', help='specify the SMTP port', type="int")
|
||||
group.add_option('--smtp-ssl', dest='smtp_ssl', default='', help='specify the SMTP server support SSL or not')
|
||||
group.add_option('--smtp-user', dest='smtp_user', default='', help='specify the SMTP username for sending email')
|
||||
group.add_option('--smtp-password', dest='smtp_password', default='', help='specify the SMTP password for sending email')
|
||||
group.add_option('--email-from', dest='email_from', help='specify the SMTP email address for sending email')
|
||||
group.add_option('--smtp', dest='smtp_server', help='specify the SMTP server for sending email')
|
||||
group.add_option('--smtp-port', dest='smtp_port', help='specify the SMTP port', type="int")
|
||||
group.add_option('--smtp-ssl', dest='smtp_ssl', action='store_true', help='specify the SMTP server support SSL or not')
|
||||
group.add_option('--smtp-user', dest='smtp_user', help='specify the SMTP username for sending email')
|
||||
group.add_option('--smtp-password', dest='smtp_password', help='specify the SMTP password for sending email')
|
||||
parser.add_option_group(group)
|
||||
|
||||
group = optparse.OptionGroup(parser, "Database related options")
|
||||
@@ -190,7 +192,7 @@ class configmanager(object):
|
||||
group.add_option("--pg_path", dest="pg_path", help="specify the pg executable path")
|
||||
group.add_option("--db_host", dest="db_host", help="specify the database host")
|
||||
group.add_option("--db_port", dest="db_port", help="specify the database port", type="int")
|
||||
group.add_option("--db_maxconn", dest="db_maxconn", default='64',
|
||||
group.add_option("--db_maxconn", dest="db_maxconn", type='int',
|
||||
help="specify the the maximum number of physical connections to posgresql")
|
||||
group.add_option("-P", "--import-partial", dest="import_partial",
|
||||
help="Use this for big data importation, if it crashes you will be able to continue at the current state. Provide a filename to store intermediate importation states.", default=False)
|
||||
@@ -216,7 +218,7 @@ class configmanager(object):
|
||||
parser.add_option_group(group)
|
||||
|
||||
security = optparse.OptionGroup(parser, 'Security-related options')
|
||||
security.add_option('--no-database-list', action="store_false", dest='list_db', default=True, help="disable the ability to return the list of databases")
|
||||
security.add_option('--no-database-list', action="store_false", dest='list_db', help="disable the ability to return the list of databases")
|
||||
security.add_option('--enable-code-actions', action='store_true',
|
||||
dest='server_actions_allow_code', default=False,
|
||||
help='Enables server actions of state "code". Warning, this is a security risk.')
|
||||
@@ -267,8 +269,8 @@ class configmanager(object):
|
||||
self.options['pidfile'] = False
|
||||
|
||||
keys = ['xmlrpc_interface', 'xmlrpc_port', 'db_name', 'db_user', 'db_password', 'db_host',
|
||||
'db_port', 'list_db', 'logfile', 'pidfile', 'smtp_port', 'cache_timeout','smtp_ssl',
|
||||
'email_from', 'smtp_server', 'smtp_user', 'smtp_password',
|
||||
'db_port', 'logfile', 'pidfile', 'smtp_port', 'cache_timeout',
|
||||
'email_from', 'smtp_server', 'smtp_user', 'smtp_password',
|
||||
'netrpc_interface', 'netrpc_port', 'db_maxconn', 'import_partial', 'addons_path',
|
||||
'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone',
|
||||
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
|
||||
@@ -280,9 +282,9 @@ class configmanager(object):
|
||||
if getattr(opt, arg):
|
||||
self.options[arg] = getattr(opt, arg)
|
||||
|
||||
keys = ['language', 'translate_out', 'translate_in', 'debug_mode',
|
||||
keys = ['language', 'translate_out', 'translate_in', 'debug_mode', 'smtp_ssl',
|
||||
'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
|
||||
'list_db', 'server_actions_allow_code', 'xmlrpcs',
|
||||
'list_db', 'server_actions_allow_code', 'xmlrpcs',
|
||||
'test_file', 'test_disable', 'test_commit'
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user