<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>
<!--
======================
</form>
</field>
</record>
-
+
<!--
======================
Users
<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>
from osv import fields,osv
import tools
+import pytz
class groups(osv.osv):
_name = "res.groups"
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
'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)
]
_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):
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()
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):
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: