From b57ed69d1210311a65c8b9aceb83ab07f4272e0a Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Thu, 1 Nov 2012 17:52:11 +0530 Subject: [IMP] add stages when creating a user in the group Employee. bzr revid: nco@tinyerp.com-20121101122211-wbshr2x4ltry1t98 --- addons/note/note.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index 9d62f7a2cb7..faeecea0d55 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -186,3 +186,24 @@ class note_base_config_settings(osv.osv_memory): 'module_note_pad': fields.boolean('Use collaborative pads (etherpad)'), 'group_note_fancy': fields.boolean('Use fancy layouts for notes', implied_group='note.group_note_fancy'), } + +class res_users(osv.Model): + _name = 'res.users' + _inherit = ['res.users'] + def create(self, cr, uid, data, context=None): + user_id = super(res_users, self).create(cr, uid, data, context=context) + note_obj = self.pool.get('note.stage') + data_obj = self.pool.get('ir.model.data') + model_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user') + group_id = model_id and model_id[1] or False + if not group_id: return user_id + cr.execute('SELECT * FROM res_groups_users_rel WHERE uid = %s and gid = %s', (user_id, group_id,)) + if not cr.fetchone(): + return user_id + note_ids = ['note_stage_01','note_stage_02','note_stage_03','note_stage_04'] + for note_id in note_ids: + data_id = data_obj._get_id(cr, uid, 'note', note_id) + view_id = data_obj.browse(cr, uid, data_id, context=context).res_id + note_obj.copy(cr, uid, view_id, default = { + 'user_id': user_id}, context=context) + return user_id \ No newline at end of file -- cgit v1.2.3 From f11b8c3b0136166e28614cb68b3513cbe4ad40bd Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Fri, 2 Nov 2012 17:12:41 +0530 Subject: [IMP] add translate true on name filed of note stage. bzr revid: nco@tinyerp.com-20121102114241-qq4g3rc0hwtcuq3e --- addons/note/note.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index faeecea0d55..ab329644250 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -29,7 +29,7 @@ class note_stage(osv.osv): _name = "note.stage" _description = "Note Stage" _columns = { - 'name': fields.char('Stage Name', required=True), + 'name': fields.char('Stage Name', translate=True, required=True), 'sequence': fields.integer('Sequence', help="Used to order the note stages"), 'user_id': fields.many2one('res.users', 'Owner', help="Owner of the note stage.", required=True), 'fold': fields.boolean('Folded by Default'), -- cgit v1.2.3 From fd0ea2a2e6cd7a9858c3feaf3531d5b88a5bbbc1 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Fri, 2 Nov 2012 18:47:59 +0530 Subject: [IMP] improve code. bzr revid: nco@tinyerp.com-20121102131759-e7q27o3w2npu9mgr --- addons/note/note.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index ab329644250..fe5eca5efd7 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -192,18 +192,15 @@ class res_users(osv.Model): _inherit = ['res.users'] def create(self, cr, uid, data, context=None): user_id = super(res_users, self).create(cr, uid, data, context=context) + user = self.browse(cr, uid, uid, context=context) note_obj = self.pool.get('note.stage') data_obj = self.pool.get('ir.model.data') - model_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user') + model_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user') #Employee Group group_id = model_id and model_id[1] or False - if not group_id: return user_id - cr.execute('SELECT * FROM res_groups_users_rel WHERE uid = %s and gid = %s', (user_id, group_id,)) - if not cr.fetchone(): - return user_id - note_ids = ['note_stage_01','note_stage_02','note_stage_03','note_stage_04'] - for note_id in note_ids: - data_id = data_obj._get_id(cr, uid, 'note', note_id) - view_id = data_obj.browse(cr, uid, data_id, context=context).res_id - note_obj.copy(cr, uid, view_id, default = { - 'user_id': user_id}, context=context) + if group_id in [x.id for x in user.groups_id]: + for note_xml_id in ['note_stage_01','note_stage_02','note_stage_03','note_stage_04']: + data_id = data_obj._get_id(cr, uid, 'note', note_xml_id) + stage_id = data_obj.browse(cr, uid, data_id, context=context).res_id + note_obj.copy(cr, uid, stage_id, default = { + 'user_id': user_id}, context=context) return user_id \ No newline at end of file -- cgit v1.2.3