diff --git a/bin/addons/base/base_security.xml b/bin/addons/base/base_security.xml index 28de043d36e..7e573b5fecb 100644 --- a/bin/addons/base/base_security.xml +++ b/bin/addons/base/base_security.xml @@ -34,10 +34,10 @@ --> Root - - + + - - ir.actions.actions Employee - - - - - - - - - - ir_actions_wizard group_employee - - - - - - - - - - - - - ir_act_window group_employee - + @@ -336,7 +311,7 @@ ir_act_window_view group_employee - + @@ -346,7 +321,7 @@ ir_model_data group_employee - + @@ -356,7 +331,7 @@ ir_model_fields group_employee - + @@ -366,7 +341,7 @@ ir_module_category group_employee - + @@ -376,7 +351,7 @@ ir_module_module group_employee - + @@ -384,9 +359,19 @@ + + ir_property group_employee + + + + + + + + ir_rule group_employee - + @@ -396,7 +381,7 @@ ir_rule_group group_employee - + @@ -406,7 +391,7 @@ ir_ui_menu group_employee - + @@ -416,7 +401,7 @@ ir_ui_view group_employee - + @@ -426,7 +411,7 @@ ir_ui_view_sc group_employee - + @@ -434,275 +419,25 @@ - - res_company group_employee - + + ir_values group_employee + - + - - res_company group_erp_manager - + + ir_values group_erp_manager + - - - - - - - - res_country group_employee - - - - - - - - - - res_country_state group_employee - - - - - - - - - - res_currency group_employee - - - - - - - - - - res_currency_rate group_employee - - - - - - - - - - res_currency_rate group_account_manager - - - - - - - - - - res_groups group_erp_manager - - - - - - - - - - res_lang group_employee - - - - - - - - - - res_partner group_employee - - - - - - - - - - res_partner_address group_employee - - - - - - - - - - res_partner_bank group_employee - - - - - - - - - - res_partner_bank_type group_employee - - - - - - - - - - res_partner_bank_type_field group_employee - - - - - - - - - - res_partner_canal group_employee - - - - - - - - - - res_partner_category group_employee - - - - - - - - - - res_partner_event group_employee - - - - - - - - - - res_partner_event_type group_employee - - - - - - - - - - res_partner_function group_employee - - - - - - - - - - res_partner_som group_employee - - - - - - - - - - res_partner_title group_employee - - - - - - - - - - res_request group_request - - - - - - - - - - res_request group_employee - - - - - - - - - - res_request_history group_employee - - - - - - - - - - res_request_link group_employee - - - - - - - - - - res_users group_employee - - - + - - res_users group_erp_manager - - - - - - - - diff --git a/bin/addons/base/base_update.xml b/bin/addons/base/base_update.xml index 4597ccfa487..a23c2ad7dcb 100644 --- a/bin/addons/base/base_update.xml +++ b/bin/addons/base/base_update.xml @@ -61,14 +61,14 @@ - - - - - - - - + + + + + + + + diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index 30bd64a3aad..853cd785741 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -643,7 +643,7 @@ - + @@ -947,7 +947,7 @@ Cron Jobs - Define Access + Access Structure ir.model form form,tree @@ -956,12 +956,12 @@ Cron Jobs - + - - + + @@ -978,9 +978,9 @@ Cron Jobs - - - + + + @@ -1013,8 +1013,8 @@ Cron Jobs form - - + + @@ -1095,8 +1095,8 @@ Cron Jobs - - + + diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 4a75555fa99..340778103b8 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -1,6 +1,7 @@ ############################################################################## # # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Copyright (c) 2008 Camptocamp SA # # $Id$ # @@ -60,11 +61,6 @@ class ir_model(osv.osv): 'state': lambda self,cr,uid,ctx={}: (ctx and ctx.get('manual',False)) and 'manual' or 'base', } - #FIXME: We'll be back soon - #_constraints = [ - # (_check_model_name, 'The model name must start with x_ and not contain any special character !', ['model']), - #] - def _check_model_name(self, cr, uid, ids): for model in self.browse(cr, uid, ids): if model.state=='manual': @@ -73,6 +69,11 @@ class ir_model(osv.osv): if not re.match('^[a-z_A-Z0-9]+$',model.model): return False return True + + #FIXME: We'll be back soon + #_constraints = [ + # (_check_model_name, 'The model name must start with x_ and not contain any special character !', ['model']), + #] def instanciate(self, cr, user, model, context={}): class x_custom_model(osv.osv): @@ -193,7 +194,7 @@ class ir_model(osv.osv): groups_br = self.pool.get('res.groups').browse(cr, uid, groups) cols = ['model', 'type'] - xml = '''''' + xml = '''''' for group in groups_br: xml += '''''' % (group.id, group.name) xml += '''''' @@ -280,7 +281,7 @@ class ir_model_access(osv.osv): res = False grouparr = group.split('.') if grouparr: - cr.execute("select * from res_groups_users_rel where uid=" + str(uid) + " and gid in(select res_id from ir_model_data where module='%s' and name='%s')", (grouparr[0], grouparr[1],)) + cr.execute("select * from res_groups_users_rel where uid=" + str(uid) + " and gid in(select res_id from ir_model_data where module=%s and name=%s)", (grouparr[0], grouparr[1],)) r = cr.fetchall() if not r: res = False @@ -290,6 +291,15 @@ class ir_model_access(osv.osv): res = False return res + def check_groups_by_id(self, cr, uid, group_id): + cr.execute("select * from res_groups_users_rel where uid=%i and gid=%i", (uid, group_id,)) + r = cr.fetchall() + if not r: + res = False + else: + res = True + return res + def check(self, cr, uid, model_name, mode='read',raise_exception=True): # Users root have all access (Todo: exclude xml-rpc requests) if uid==1: diff --git a/bin/addons/base/res/res_security.xml b/bin/addons/base/res/res_security.xml index 1ce91472707..cb2be2a3d71 100644 --- a/bin/addons/base/res/res_security.xml +++ b/bin/addons/base/res/res_security.xml @@ -102,6 +102,285 @@ + + res_company group_employee + + + + + + + + + + res_company group_erp_manager + + + + + + + + + + res_country group_employee + + + + + + + + + + res_country_state group_employee + + + + + + + + + + res_currency group_employee + + + + + + + + + + res_currency_rate group_employee + + + + + + + + + + res_currency_rate group_account_manager + + + + + + + + + + res_groups group_employee + + + + + + + + + + res_groups group_erp_manager + + + + + + + + + + res_lang group_employee + + + + + + + + + + res_partner group_employee + + + + + + + + + + res_partner_address group_employee + + + + + + + + + + res_partner_bank group_employee + + + + + + + + + + res_partner_bank_type group_employee + + + + + + + + + + res_partner_bank_type_field group_employee + + + + + + + + + + res_partner_canal group_employee + + + + + + + + + + res_partner_category group_employee + + + + + + + + + + res_partner_event group_employee + + + + + + + + + + res_partner_event_type group_employee + + + + + + + + + + res_partner_function group_employee + + + + + + + + + + res_partner_som group_employee + + + + + + + + + + res_partner_title group_employee + + + + + + + + + + res_request group_request + + + + + + + + + + res_request group_employee + + + + + + + + + + res_request_history group_employee + + + + + + + + + + res_request_link group_employee + + + + + + + + + + res_users group_employee + + + + + + + + + + res_users group_erp_manager + + + + + + + diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 752bd7fc546..5aa2b98013c 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -1,6 +1,7 @@ ############################################################################## # # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Copyright (c) 2008 Camptocamp SA # # $Id$ # @@ -73,7 +74,7 @@ class roles(osv.osv): 'parent_id': fields.many2one('res.roles', 'Parent', select=True), 'child_id': fields.one2many('res.roles', 'parent_id', 'Childs'), 'users': fields.many2many('res.users', 'res_roles_users_rel', 'rid', 'uid', 'Users'), - 'groups': fields.many2many('res.groups', 'res_roles_groups_rel', 'rid', 'gid', 'Groups'), + #'groups': fields.many2many('res.groups', 'res_roles_groups_rel', 'rid', 'gid', 'Groups'), } _defaults = { } @@ -156,17 +157,23 @@ class users(osv.osv): self.pool.get('ir.rule').domain_get() else: raise except_orm(_('AccessError'), 'You can not write in this document (res.users)') + + #Only root can change root password + user_obj_towrite=self.pool.get('res.users').read(cr, uid, uid) + if user_obj_towrite['login']=='root' and uid!=1: + raise osv.except_osv('UserError', 'Only admin user can change admin password') return res - def read(self,cr, uid, ids, fields=None, context=None, load='_classic_read'): - result = super(users, self).read(cr, uid, ids, fields, context, load) + #def read(self,cr, uid, ids, fields=None, context=None, load='_classic_read'): + #result = super(users, self).read(cr, uid, ids, fields, context, load) + #print result #canwrite = self.pool.get('ir.model.access').check(cr, uid, 'res.users', 'write', raise_exception=False) #if not canwrite and ids!=[uid]: # for r in result: # if 'password' in r: # r['password'] = '********' # result=r - return result + #return result def unlink(self, cr, uid, ids): if 1 in ids: @@ -244,7 +251,7 @@ class groups2(osv.osv): ##FIXME: Is there a reason to inherit this object ? _inherit = 'res.groups' _columns = { 'users': fields.many2many('res.users', 'res_groups_users_rel', 'gid', 'uid', 'Users'), - 'roles': fields.many2many('res.roles', 'res_roles_groups_rel', 'gid', 'rid', 'Roles'), + #'roles': fields.many2many('res.roles', 'res_roles_groups_rel', 'gid', 'rid', 'Roles'), } groups2() diff --git a/bin/addons/board b/bin/addons/board new file mode 120000 index 00000000000..85a77dbe95c --- /dev/null +++ b/bin/addons/board @@ -0,0 +1 @@ +../../../openobject-addons/board \ No newline at end of file diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 3fdaddfa92c..23bd4cc4d40 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -2,6 +2,7 @@ ############################################################################## # # Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved. +# Copyright (c) 2008 Camptocamp SA # # $Id$ # @@ -823,30 +824,37 @@ class orm_template(object): if not context: context={} fields_def = self.__view_look_dom(cr, user, node, context=context) - + buttons = xpath.Evaluate('//button', node) if buttons: for button in buttons: if button.getAttribute('type') == 'object': continue - + ok = True - + serv = netsvc.LocalService('object_proxy') user_roles = serv.execute_cr(cr, user, 'res.users', 'read', [user], ['roles_id'])[0]['roles_id'] cr.execute("select role_id from wkf_transition where signal='%s'" % button.getAttribute('name')) roles = cr.fetchall() for role in roles: if role[0]: + # Check if group is in role + #cr.execute("select gid from res_roles_groups_rel where rid=%i", (role[0],)) + #groups = cr.fetchall() + #if len(groups)>0: + # for group in groups: + # ok = self.pool.get('ir.model.access').check_groups_by_id(cr, user, group[0]) + #else: ok = ok and serv.execute_cr(cr, user, 'res.roles', 'check', user_roles, role[0]) - + if not ok: button.setAttribute('readonly', '1') else: button.setAttribute('readonly', '0') - + print ok + arch = node.toxml(encoding="utf-8").replace('\t', '') - fields = self.fields_get(cr, user, fields_def.keys(), context) for field in fields_def: fields[field].update(fields_def[field])