[IMP]Base:Change Fun -default set in Define default users preferences confg wiz

bzr revid: aag@tinyerp.co.in-20110406102945-jw0dfand32hf7p0h
This commit is contained in:
aag (OpenERP) 2011-04-06 15:59:45 +05:30
parent 386090a16f
commit feb56699b3
2 changed files with 10 additions and 14 deletions

View File

@ -434,7 +434,7 @@
</xpath> </xpath>
<xpath expr="//label[@string='description']" <xpath expr="//label[@string='description']"
position="attributes"> position="attributes">
<attribute name="string">Set Timezone,Language,Interface,MenuTip as default for all users by company.</attribute> <attribute name="string">Specify default values. These data are just default values, each user is free to change his own preferences.</attribute>
</xpath> </xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'> <xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='string'></attribute> <attribute name='string'></attribute>
@ -442,7 +442,6 @@
</xpath> </xpath>
<group string="res_config_contents" position="replace"> <group string="res_config_contents" position="replace">
<group colspan="4"> <group colspan="4">
<field colspan="4" name="company_id" />
<field colspan="4" name="context_tz" /> <field colspan="4" name="context_tz" />
<field colspan="4" name="context_lang" /> <field colspan="4" name="context_lang" />
<field colspan="4" name="view" /> <field colspan="4" name="view" />

View File

@ -610,13 +610,11 @@ class user_preferences_config(osv.osv_memory):
_name = 'user.preferences.config' _name = 'user.preferences.config'
_inherit = 'res.config' _inherit = 'res.config'
_columns = { _columns = {
'company_id': fields.many2one('res.company', 'Company', required=True,
help="Select company for configure by company ."),
'context_tz': fields.selection(_tz_get, 'Timezone', size=64, 'context_tz': fields.selection(_tz_get, 'Timezone', size=64,
help="The company's timezone, used to perform timezone conversions " help="Set default for new user's timezone, used to perform timezone conversions "
"between the server and the client."), "between the server and the client."),
'context_lang': fields.selection(_lang_get, 'Language', required=True, 'context_lang': fields.selection(_lang_get, 'Language', required=True,
help="Sets the language for the company's user interface, when UI " help="Sets default language for the new user's user interface, when UI "
"translations are available"), "translations are available"),
'view': fields.selection([('simple','Simplified'), 'view': fields.selection([('simple','Simplified'),
('extended','Extended')], ('extended','Extended')],
@ -625,19 +623,18 @@ class user_preferences_config(osv.osv_memory):
} }
_defaults={ _defaults={
'company_id':lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
'view':lambda self,cr,uid,*args: self.pool.get('res.users').browse(cr, uid, uid).view or 'simple', 'view':lambda self,cr,uid,*args: self.pool.get('res.users').browse(cr, uid, uid).view or 'simple',
'context_lang':'en_US', 'context_lang':'en_US',
} }
def execute(self, cr, uid, ids, context=None): def execute(self, cr, uid, ids, context=None):
usr_obj = self.pool.get("res.users") for o in self.browse(cr, uid, ids, context=context):
get_val = self.browse(cr, uid, ids)[0] ir_values_obj = self.pool.get('ir.values')
data_ids = usr_obj.search(cr,uid,[('company_id','=',get_val.company_id.id)]) ir_values_obj.set(cr, uid, 'default', False, 'context_tz', ['res.users'], o.context_tz)
if data_ids: ir_values_obj.set(cr, uid, 'default', False, 'context_lang', ['res.users'], o.context_lang)
for w_id in data_ids: ir_values_obj.set(cr, uid, 'default', False, 'view', ['res.users'], o.view)
usr_obj.write(cr, uid, [w_id], {'context_tz': get_val.context_tz,'context_lang':get_val.context_lang,'view':get_val.view,'menu_tips':get_val.menu_tips}) ir_values_obj.set(cr, uid, 'default', False, 'menu_tips', ['res.users'], o.menu_tips)
return True return {}
user_preferences_config() user_preferences_config()