Improvements
bzr revid: fp@tinyerp.com-dd48c1c3ca315d8ee6bf962b6af334ade92a0fc7
This commit is contained in:
parent
326bbb4dce
commit
17db037990
|
@ -26,26 +26,6 @@
|
|||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem name="Administration/Custom/Interface/Languages" action="action_lang" id="menu_action_lang"/>
|
||||
|
||||
<ir_set>
|
||||
<field name="key" eval="'meta'"/>
|
||||
<field name="key2" eval="'lang'"/>
|
||||
<field name="models" eval="['res.users']"/>
|
||||
<field name="name">lang</field>
|
||||
<field name="value" eval="False"/>
|
||||
<field name="meta" eval="{'type':'selection', 'string':'Language', 'selection':[('en_US', 'English')]}"/>
|
||||
<field name="replace" eval="True"/>
|
||||
</ir_set>
|
||||
|
||||
<ir_set>
|
||||
<field name="key" eval="'meta'"/>
|
||||
<field name="key2" eval="'tz'"/>
|
||||
<field name="models" eval="['res.users']"/>
|
||||
<field name="name">tz</field>
|
||||
<field name="value" eval="False"/>
|
||||
<field name="meta" eval="{'type':'selection', 'string':'Timezone', 'selection': [(x, x) for x in pytz.all_timezones] }"/>
|
||||
<field name="replace" eval="True"/>
|
||||
</ir_set>
|
||||
|
||||
<!--
|
||||
======================
|
||||
|
@ -84,7 +64,7 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!--
|
||||
======================
|
||||
Users
|
||||
|
@ -97,30 +77,16 @@
|
|||
<field name="priority" eval="10"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Users">
|
||||
<field name="name" colspan="4" select="1"/>
|
||||
<field name="login" readonly="1" select="1"/>
|
||||
<field name="password"/>
|
||||
<label string="Please note that you will have to logout and relog if you change your password." colspan="4"/>
|
||||
<field name="context_lang"/>
|
||||
<field name="context_tz"/>
|
||||
<newline/>
|
||||
<field name="signature" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_users_form_simple">
|
||||
<field name="name">res.users.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority" eval="8"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Users">
|
||||
<field name="name" readonly="1" colspan="4" select="1"/>
|
||||
<field name="login" readonly="1" select="1"/>
|
||||
<field name="active" readonly="1" select="1"/>
|
||||
<newline/>
|
||||
<field name="signature" readonly="1" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_users_form">
|
||||
<field name="name">res.users.form</field>
|
||||
<field name="model">res.users</field>
|
||||
|
|
|
@ -378,7 +378,7 @@
|
|||
<menuitem name="Administration/Users/Users" action="action_res_users" id="menu_action_res_users"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_res_users_my">
|
||||
<field name="name">Change My Password</field>
|
||||
<field name="name">Change My Preferences</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">res.users</field>
|
||||
<field name="view_type">form</field>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
from osv import fields,osv
|
||||
import tools
|
||||
import pytz
|
||||
|
||||
class groups(osv.osv):
|
||||
_name = "res.groups"
|
||||
|
@ -82,6 +83,13 @@ class roles(osv.osv):
|
|||
return False
|
||||
roles()
|
||||
|
||||
def _lang_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.lang')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['code', 'name'], context)
|
||||
res = [(r['code'], r['name']) for r in res]
|
||||
return res
|
||||
|
||||
class users(osv.osv):
|
||||
_name = "res.users"
|
||||
_log_access = False
|
||||
|
@ -98,6 +106,8 @@ class users(osv.osv):
|
|||
'roles_id': fields.many2many('res.roles', 'res_roles_users_rel', 'uid', 'rid', 'Roles'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'rule_groups': fields.many2many('ir.rule.group', 'user_rule_group_rel', 'user_id', 'rule_group_id', 'Rules', domain="[('global', '<>', True)]"),
|
||||
'context_lang': fields.selection(_lang_get, 'Language', required=True),
|
||||
'context_tz': fields.selection([(x, x) for x in pytz.all_timezones], 'Timezone')
|
||||
}
|
||||
def read(self,cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
result = super(users, self).read(cr, uid, ids, fields, context, load)
|
||||
|
@ -113,6 +123,7 @@ class users(osv.osv):
|
|||
]
|
||||
_defaults = {
|
||||
'password' : lambda obj,cr,uid,context={} : '',
|
||||
'context_lang': lambda *args: 'en_US',
|
||||
'active' : lambda obj,cr,uid,context={} : True,
|
||||
}
|
||||
def company_get(self, cr, uid, uid2):
|
||||
|
@ -120,8 +131,15 @@ class users(osv.osv):
|
|||
return company_id
|
||||
company_get = tools.cache()(company_get)
|
||||
|
||||
def write(self, cr, uid, *args, **argv):
|
||||
res = super(users, self).write(cr, uid, *args, **argv)
|
||||
def write(self, cr, uid, ids, values, *args, **argv):
|
||||
if (ids == [uid]):
|
||||
ok = True
|
||||
for k in values.keys():
|
||||
if k not in ('password','signature','action_id', 'context_lang', 'context_tz'):
|
||||
ok=False
|
||||
if ok:
|
||||
uid = 1
|
||||
res = super(users, self).write(cr, uid, ids, values, *args, **argv)
|
||||
self.company_get()
|
||||
# Restart the cache on the company_get method
|
||||
self.pool.get('ir.rule').domain_get()
|
||||
|
@ -148,6 +166,19 @@ class users(osv.osv):
|
|||
login = self.read(cr, uid, [id], ['login'])[0]['login']
|
||||
default.update({'login': login+' (copy)'})
|
||||
return super(users, self).copy(cr, uid, id, default, context)
|
||||
|
||||
def context_get(self, cr, uid, context={}):
|
||||
user = self.browse(cr, uid, uid, context)
|
||||
result = {}
|
||||
for k in self._columns.keys():
|
||||
if k.startswith('context_'):
|
||||
result[k[8:]] = getattr(user,k)
|
||||
return result
|
||||
|
||||
def action_get(self, cr, uid, context={}):
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
data_id = dataobj._get_id(cr, 1, 'base', 'action_res_users_my')
|
||||
return dataobj.browse(cr, uid, data_id, context).res_id
|
||||
users()
|
||||
|
||||
class groups2(osv.osv):
|
||||
|
|
|
@ -337,6 +337,7 @@ class _rml_canvas(object):
|
|||
else:
|
||||
import base64
|
||||
image_data = base64.decodestring(node.firstChild.nodeValue)
|
||||
if not image_data: return False
|
||||
s = StringIO.StringIO(image_data)
|
||||
else:
|
||||
if node.getAttribute('file') in self.images:
|
||||
|
|
|
@ -139,7 +139,7 @@ except psycopg.OperationalError:
|
|||
logger.notifyChannel("init", netsvc.LOG_INFO, "could not connect to database '%s'!" % db_name,)
|
||||
cr = None
|
||||
if cr:
|
||||
cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='perm'")
|
||||
cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_ui_menu'")
|
||||
if len(cr.fetchall())==0:
|
||||
#if False:
|
||||
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
|
||||
|
|
|
@ -317,18 +317,6 @@ def trans_load_data(db_name, data, lang, strict=False, lang_name=None):
|
|||
langs = lang_obj.read(cr, uid, lang_ids)
|
||||
ls = map(lambda x: (x['code'],x['name']), langs)
|
||||
|
||||
ir.ir_set(cr, uid, 'meta', 'lang', 'lang', [('res.users',False,)],
|
||||
False, True, False, meta={
|
||||
'type': 'selection',
|
||||
'string': 'Language',
|
||||
'selection':ls,
|
||||
})
|
||||
|
||||
ids = pool.get('res.users').search(cr, uid, [])
|
||||
for id in ids:
|
||||
ir.ir_set(cr, uid, 'meta', 'lang', 'lang', [('res.users',id,)],
|
||||
lang, True, False)
|
||||
|
||||
reader = csv.reader(data)
|
||||
# read the first line of the file (it contains columns titles)
|
||||
for row in reader:
|
||||
|
|
Loading…
Reference in New Issue