diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 172e150740d..a58a50028a5 100755 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -73,7 +73,7 @@ class crm_case_section(osv.osv): 'user_id': fields.many2one('res.users', 'Responsible User'), 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this section"), 'parent_id': fields.many2one('crm.case.section', 'Parent Section'), - 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'), + 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'), 'calendar' : fields.boolean('Calendar', help='Allows to show calendar'), } _defaults = { @@ -408,6 +408,11 @@ class crm_case(osv.osv): if context.get('portal', False): return False return uid + + def _get_section(self, cr, uid, context): + user = self.pool.get('res.users').browse(cr, uid, uid) + return user.section_id.id + _defaults = { 'active': lambda *a: 1, 'user_id': _get_default_user, @@ -417,6 +422,7 @@ class crm_case(osv.osv): 'state': lambda *a: 'draft', 'priority': lambda *a: AVAILABLE_PRIORITIES[2][0], 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), + 'section_id': _get_section, } _order = 'priority, date_deadline desc, date desc,id desc' @@ -818,8 +824,8 @@ class crm_case(osv.osv): data['user_id'] = uid self.write(cr, uid, ids, data) self._action(cr,uid, cases, 'open') - return True - + return True + def case_cancel(self, cr, uid, ids, *args): cases = self.browse(cr, uid, ids) @@ -946,5 +952,15 @@ class crm_email_add_cc_wizard(osv.osv_memory): return {} crm_email_add_cc_wizard() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +class res_users(osv.osv): + _inherit = "res.users" + _description = "users" + + _columns = { + 'section_id': fields.many2one('crm.case.section', 'Sales Section', required=False) + } + +res_users() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/crm/crm_claim.py b/addons/crm/crm_claim.py index 1cddafaeca8..0606e39a052 100644 --- a/addons/crm/crm_claim.py +++ b/addons/crm/crm_claim.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -30,15 +30,15 @@ class crm_claim(osv.osv): _name = "crm.claim" _description = "Claim Cases" _order = "id desc" - _inherits = {'crm.case':"inherit_case_id"} - _columns = { + _inherits = {'crm.case':"inherit_case_id"} + _columns = { 'inherit_case_id': fields.many2one('crm.case','Case',ondelete='cascade'), } def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: - select = ids + select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: @@ -61,25 +61,25 @@ class crm_claim(osv.osv): def onchange_categ_id(self, cr, uid, ids, *args, **argv): return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv) def case_close(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_close',cr,uid,ids,*args,**argv) + return self._map_ids('case_close',cr,uid,ids,*args,**argv) def case_open(self,cr, uid, ids, *args, **argv): return self._map_ids('case_open',cr,uid,ids,*args,**argv) def case_cancel(self,cr, uid, ids, *args, **argv): return self._map_ids('case_cancel',cr,uid,ids,*args,**argv) def case_reset(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_reset',cr,uid,ids,*args,**argv) - def case_escalate(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) - def case_pending(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_pending',cr,uid,ids,*args,**argv) + return self._map_ids('case_reset',cr,uid,ids,*args,**argv) + def case_escalate(self,cr, uid, ids, *args, **argv): + return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) + def case_pending(self,cr, uid, ids, *args, **argv): + return self._map_ids('case_pending',cr,uid,ids,*args,**argv) - def msg_new(self, cr, uid, msg): + def msg_new(self, cr, uid, msg): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { - 'name': msg['Subject'], + 'name': msg['Subject'], 'email_from': msg['From'], - 'email_cc': msg['Cc'], + 'email_cc': msg['Cc'], 'user_id': False, 'description': msg_body['body'], 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], @@ -87,15 +87,15 @@ class crm_claim(osv.osv): res = mailgate_obj.partner_get(cr, uid, msg['From']) if res: data.update(res) - res = self.create(cr, uid, data) + res = self.create(cr, uid, data) return res def msg_update(self, cr, uid, ids, *args, **argv): return self._map_ids('msg_update',cr, uid, ids, *args, **argv) def emails_get(self, cr, uid, ids, *args, **argv): return self._map_ids('emails_get',cr, uid, ids, *args, **argv) - def msg_send(self, cr, uid, ids, *args, **argv): - return self._map_ids('msg_send',cr, uid, ids, *args, **argv) + def msg_send(self, cr, uid, ids, *args, **argv): + return self._map_ids('msg_send',cr, uid, ids, *args, **argv) crm_claim() @@ -103,7 +103,7 @@ class crm_claim_assign_wizard(osv.osv_memory): _name = 'crm.claim.assign_wizard' _columns = { - 'section_id': fields.many2one('crm.case.section', 'Section', required=True), + 'section_id': fields.many2one('crm.case.section', 'Section', required=False), 'user_id': fields.many2one('res.users', 'Responsible'), } @@ -133,18 +133,18 @@ class crm_claim_assign_wizard(osv.osv_memory): 'section_id':res.get('section_id',False), 'user_id':res.get('user_id',False), 'case_id' : case.inherit_case_id.id - }, context=context) + }, context=context) case_obj.case_close(cr, uid, [case_id]) data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_claims_filter') search_view = data_obj.read(cr, uid, result, ['res_id']) - value = { + value = { 'name': _('Claims'), 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'crm.claim', - 'res_id': int(new_case_id), + 'res_id': int(new_case_id), 'type': 'ir.actions.act_window', 'search_view_id': search_view['res_id'] } diff --git a/addons/crm/crm_helpdesk.py b/addons/crm/crm_helpdesk.py index b4ecbc728d2..4cf4b951e53 100644 --- a/addons/crm/crm_helpdesk.py +++ b/addons/crm/crm_helpdesk.py @@ -36,16 +36,16 @@ class crm_helpdesk(osv.osv): _name = "crm.helpdesk" _description = "Helpdesk Cases" _order = "id desc" - _inherits = {'crm.case':"inherit_case_id"} - _columns = { + _inherits = {'crm.case':"inherit_case_id"} + _columns = { 'inherit_case_id':fields.many2one('crm.case','Case'), } - + def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: - select = ids + select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: @@ -66,21 +66,21 @@ class crm_helpdesk(osv.osv): def onchange_categ_id(self, cr, uid, ids, *args, **argv): return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv) def case_close(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_close',cr,uid,ids,*args,**argv) + return self._map_ids('case_close',cr,uid,ids,*args,**argv) def case_open(self,cr, uid, ids, *args, **argv): return self._map_ids('case_open',cr,uid,ids,*args,**argv) def case_cancel(self,cr, uid, ids, *args, **argv): return self._map_ids('case_cancel',cr,uid,ids,*args,**argv) def case_reset(self,cr, uid, ids, *args, **argv): return self._map_ids('case_reset',cr,uid,ids,*args,**argv) - - def msg_new(self, cr, uid, msg): + + def msg_new(self, cr, uid, msg): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { - 'name': msg['Subject'], + 'name': msg['Subject'], 'email_from': msg['From'], - 'email_cc': msg['Cc'], + 'email_cc': msg['Cc'], 'user_id': False, 'description': msg_body['body'], 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], @@ -88,15 +88,15 @@ class crm_helpdesk(osv.osv): res = mailgate_obj.partner_get(cr, uid, msg['From']) if res: data.update(res) - res = self.create(cr, uid, data) + res = self.create(cr, uid, data) return res def msg_update(self, cr, uid, ids, *args, **argv): return self._map_ids('msg_update',cr, uid, ids, *args, **argv) def emails_get(self, cr, uid, ids, *args, **argv): return self._map_ids('emails_get',cr, uid, ids, *args, **argv) - def msg_send(self, cr, uid, ids, *args, **argv): - return self._map_ids('msg_send',cr, uid, ids, *args, **argv) + def msg_send(self, cr, uid, ids, *args, **argv): + return self._map_ids('msg_send',cr, uid, ids, *args, **argv) crm_helpdesk() @@ -104,7 +104,7 @@ class crm_helpdesk_assign_wizard(osv.osv_memory): _name = 'crm.helpdesk.assign_wizard' _columns = { - 'section_id': fields.many2one('crm.case.section', 'Section', required=True), + 'section_id': fields.many2one('crm.case.section', 'Section', required=False), 'user_id': fields.many2one('res.users', 'Responsible'), } diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 7f34c90d4e3..f58bdf77f20 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -35,41 +35,41 @@ class crm_meeting(osv.osv): _order = "id desc" _inherits = {'crm.case': "inherit_case_id"} __attribute__ = { - 'class': {'field': 'class', 'type': 'selection'}, + 'class': {'field': 'class', 'type': 'selection'}, 'created': {'field': 'create_date', 'type': 'datetime'}, # keep none for now - 'description': {'field': 'description', 'type': 'text'}, - 'dtstart': {'field': 'date', 'type': 'datetime'}, - 'location': {'field': 'location', 'type': 'text'}, + 'description': {'field': 'description', 'type': 'text'}, + 'dtstart': {'field': 'date', 'type': 'datetime'}, + 'location': {'field': 'location', 'type': 'text'}, #'organizer': {'field': 'partner_id', 'sub-field': 'name', 'type': 'many2one'}, - 'priority': {'field': 'priority', 'type': 'int'}, - 'dtstamp' : {'field': 'date', 'type': 'datetime'}, - 'seq': None, + 'priority': {'field': 'priority', 'type': 'int'}, + 'dtstamp' : {'field': 'date', 'type': 'datetime'}, + 'seq': None, 'status': {'field': 'state', 'type': 'selection', 'mapping': {'tentative': 'draft', \ - 'confirmed': 'open' , 'cancelled': 'cancel'}}, - 'summary': {'field': 'name', 'type': 'text'}, - 'transp': {'field': 'transparent', 'type': 'text'}, - 'uid': {'field': 'id', 'type': 'text'}, - 'url': {'field': 'caldav_url', 'type': 'text'}, - 'recurid': None, + 'confirmed': 'open' , 'cancelled': 'cancel'}}, + 'summary': {'field': 'name', 'type': 'text'}, + 'transp': {'field': 'transparent', 'type': 'text'}, + 'uid': {'field': 'id', 'type': 'text'}, + 'url': {'field': 'caldav_url', 'type': 'text'}, + 'recurid': None, # 'attach': {'field': 'attachment_ids', 'sub-field': 'datas', 'type': 'list'}, - 'attendee': {'field': 'attendee_ids', 'type': 'many2many', 'object': 'calendar.attendee'}, + 'attendee': {'field': 'attendee_ids', 'type': 'many2many', 'object': 'calendar.attendee'}, # 'categories': {'field': 'categ_id', 'sub-field': 'name'}, 'categories': {'field': 'categ_id', 'type': 'many2one', 'object': 'crm.case.categ'}, - 'comment': None, - 'contact': None, - 'exdate' : {'field': 'exdate', 'type': 'datetime'}, - 'exrule' : {'field': 'exrule', 'type': 'text'}, - 'rstatus': None, - 'related': None, - 'resources': None, - 'rdate': None, - 'rrule': {'field': 'rrule', 'type': 'text'}, - 'x-openobject-model': {'value': _name, 'type': 'text'}, + 'comment': None, + 'contact': None, + 'exdate' : {'field': 'exdate', 'type': 'datetime'}, + 'exrule' : {'field': 'exrule', 'type': 'text'}, + 'rstatus': None, + 'related': None, + 'resources': None, + 'rdate': None, + 'rrule': {'field': 'rrule', 'type': 'text'}, + 'x-openobject-model': {'value': _name, 'type': 'text'}, # 'duration': {'field': 'duration'}, - 'dtend': {'field': 'date_deadline', 'type': 'datetime'}, - 'valarm': {'field': 'caldav_alarm_id', 'type': 'many2one', 'object': 'calendar.alarm'}, + 'dtend': {'field': 'date_deadline', 'type': 'datetime'}, + 'valarm': {'field': 'caldav_alarm_id', 'type': 'many2one', 'object': 'calendar.alarm'}, } - + def _get_attendee_data(self, cr, uid, ids, name, arg, context): result = {} for id in ids: @@ -79,84 +79,84 @@ class crm_meeting(osv.osv): att_data = map(lambda x: x.cn or '', eventdata.attendee_ids) result[id] = ', '.join(att_data) return result - + def _set_attendee_data(self, cr, uid, id, name, value, arg, context): if not value: - return + return eventdata = self.browse(cr, uid, id, context=context) att_len = len(eventdata.attendee_ids) if att_len == len(value.split(',')): - return + return if att_len > len(value.split(',')): for attendee in eventdata.attendee_ids[len(value.split(',')):]: self.write(cr, uid, id, {'attendee_ids': [(3, attendee.id)]}) - return - attendee_obj = self.pool.get('calendar.attendee') + return + attendee_obj = self.pool.get('calendar.attendee') for val in value.split(',')[att_len:]: attendee_id = attendee_obj.create(cr, uid, {'cn': val.strip()}) self.write(cr, uid, id, {'attendee_ids': [(4, attendee_id)]}) - return + return _columns = { 'inherit_case_id': fields.many2one('crm.case', 'Case', ondelete='cascade'), 'class': fields.selection([('public', 'Public'), ('private', 'Private'), \ - ('confidential', 'Confidential')], 'Privacy'), - 'location': fields.char('Location', size=264, help="Gives Location of Meeting"), - 'freebusy': fields.text('FreeBusy'), + ('confidential', 'Confidential')], 'Privacy'), + 'location': fields.char('Location', size=264, help="Gives Location of Meeting"), + 'freebusy': fields.text('FreeBusy'), 'show_as': fields.selection([('free', 'Free'), \ ('busy', 'Busy')], - 'show_as'), - 'caldav_url': fields.char('Caldav URL', size=264), + 'show_as'), + 'caldav_url': fields.char('Caldav URL', size=264), 'exdate': fields.text('Exception Date/Times', help="This property defines the list\ - of date/time exceptions for arecurring calendar component."), + of date/time exceptions for arecurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="defines a rule or repeating pattern\ - for anexception to a recurrence set"), - 'rrule': fields.char('Recurrent Rule', size=352, invisible="True"), + for anexception to a recurrence set"), + 'rrule': fields.char('Recurrent Rule', size=352, invisible="True"), 'rrule_type' : fields.selection([('none', 'None'), ('daily', 'Daily'), \ - ('weekly', 'Weekly'), ('monthly', 'Monthly'), ('yearly', 'Yearly'), ('custom','Custom')], 'Recurrency'), + ('weekly', 'Weekly'), ('monthly', 'Monthly'), ('yearly', 'Yearly'), ('custom','Custom')], 'Recurrency'), 'attendees': fields.function(_get_attendee_data, method=True,\ - fnct_inv=_set_attendee_data, string='Attendees', type="text"), - 'alarm_id': fields.many2one('res.alarm', 'Alarm'), - 'caldav_alarm_id': fields.many2one('calendar.alarm', 'Alarm'), + fnct_inv=_set_attendee_data, string='Attendees', type="text"), + 'alarm_id': fields.many2one('res.alarm', 'Alarm'), + 'caldav_alarm_id': fields.many2one('calendar.alarm', 'Alarm'), 'attendee_ids': fields.many2many('calendar.attendee', 'crm_attendee_rel', 'case_id', \ - 'attendee_id', 'Attendees'), + 'attendee_id', 'Attendees'), } _defaults = { - 'class': lambda *a: 'public', + 'class': lambda *a: 'public', } def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] - - for meeting in self.browse(cr, uid, ids): + + for meeting in self.browse(cr, uid, ids): self.do_alarm_unlink(cr, uid, [meeting.id]) basic_alarm = meeting.alarm_id if basic_alarm: vals = { - 'action': 'display', - 'description': meeting.description, - 'name': meeting.name, + 'action': 'display', + 'description': meeting.description, + 'name': meeting.name, 'attendee_ids': [(6,0, map(lambda x:x.id, meeting.attendee_ids))], - 'trigger_related': basic_alarm.trigger_related, - 'trigger_duration': basic_alarm.trigger_duration, - 'trigger_occurs': basic_alarm.trigger_occurs, - 'trigger_interval': basic_alarm.trigger_interval, - 'duration': basic_alarm.duration, - 'repeat': basic_alarm.repeat, + 'trigger_related': basic_alarm.trigger_related, + 'trigger_duration': basic_alarm.trigger_duration, + 'trigger_occurs': basic_alarm.trigger_occurs, + 'trigger_interval': basic_alarm.trigger_interval, + 'duration': basic_alarm.duration, + 'repeat': basic_alarm.repeat, 'state' : 'run', - 'event_date' : meeting.date, - 'res_id' : meeting.id, + 'event_date' : meeting.date, + 'res_id' : meeting.id, 'model_id' : model_id, - 'user_id' : uid - } + 'user_id' : uid + } alarm_id = alarm_obj.create(cr, uid, vals) cr.execute('Update crm_meeting set caldav_alarm_id=%s where id=%s' % (alarm_id, meeting.id)) cr.commit() - return True - + return True + def do_alarm_unlink(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') @@ -212,7 +212,7 @@ class crm_meeting(osv.osv): crm_alarm = self.pool.get('calendar.alarm') alarm_obj.__attribute__.update(crm_alarm.__attribute__) vals = event_obj.import_ical(cr, uid, file_content) - for val in vals: + for val in vals: is_exists = common.uid2openobjectid(cr, val['id'], self._name) if val.has_key('create_date'): val.pop('create_date') val['caldav_url'] = context.get('url') or '' @@ -271,14 +271,14 @@ class crm_meeting(osv.osv): value = until_date new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) - if not is_until and until_date: + if not is_until and until_date: until_date = until_date.strftime("%Y%m%d%H%M%S") value = until_date name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) - start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") + start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: idval = common.real_id2caldav_id(data['id'], rdate) @@ -287,7 +287,7 @@ class crm_meeting(osv.osv): ids = result return ids - def search(self, cr, uid, args, offset=0, limit=100, order=None, + def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False @@ -301,7 +301,7 @@ class crm_meeting(osv.osv): elif arg[1] in ('<', '<='): until_date = arg[2] - res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, + res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, limit, order, context, count) return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit) @@ -405,18 +405,18 @@ class crm_meeting(osv.osv): if isinstance(ids, (str, int, long)) and isinstance(res, list): return res and res[0] or False return res - + def onchange_rrule_type(self, cr, uid, ids, type, *args, **argv): if type == 'none': - return {'value': {'rrule': ''}} + return {'value': {'rrule': ''}} if type == 'custom': return {} rrule = self.pool.get('caldav.set.rrule') rrulestr = rrule.compute_rule_string(cr, uid, {'freq': type.upper(),\ 'interval': 1}) - return {'value': {'rrule': rrulestr}} - - + return {'value': {'rrule': rrulestr}} + + def onchange_case_id(self, cr, uid, ids, *args, **argv): return self._map_ids('onchange_case_id', cr, uid, ids, *args, **argv) def onchange_partner_id(self, cr, uid, ids, *args, **argv): @@ -438,12 +438,12 @@ class crm_meeting(osv.osv): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { - 'name': msg['Subject'], - 'email_from': msg['From'], - 'email_cc': msg['Cc'], - 'user_id': False, - 'description': msg_body['body'], - 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], + 'name': msg['Subject'], + 'email_from': msg['From'], + 'email_cc': msg['Cc'], + 'user_id': False, + 'description': msg_body['body'], + 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], } res = mailgate_obj.partner_get(cr, uid, msg['From']) if res: @@ -465,8 +465,8 @@ class crm_meeting_generic_wizard(osv.osv_memory): _name = 'crm.meeting.generic_wizard' _columns = { - 'section_id': fields.many2one('crm.case.section', 'Section', required=True), - 'user_id': fields.many2one('res.users', 'Responsible'), + 'section_id': fields.many2one('crm.case.section', 'Section', required=False), + 'user_id': fields.many2one('res.users', 'Responsible'), } def _get_default_section(self, cr, uid, context): @@ -492,8 +492,8 @@ class crm_meeting_generic_wizard(osv.osv_memory): raise osv.except_osv(_('Error !'), _('You can not assign Closed Case.')) new_case_id = case_obj.copy(cr, uid, case_id, default= { - 'section_id': res.get('section_id', False), - 'user_id': res.get('user_id', False), + 'section_id': res.get('section_id', False), + 'user_id': res.get('user_id', False), 'case_id': case.inherit_case_id.id }, context=context) case_obj.case_close(cr, uid, [case_id]) @@ -502,11 +502,11 @@ class crm_meeting_generic_wizard(osv.osv_memory): search_view = data_obj.read(cr, uid, result, ['res_id']) new_case = case_obj.read(cr, uid, new_case_id, ['id']) value = { - 'name': _('Meetings'), - 'view_type': 'form', - 'view_mode': 'calendar, tree, form', - 'res_model': 'crm.meeting', - 'type': 'ir.actions.act_window', + 'name': _('Meetings'), + 'view_type': 'form', + 'view_mode': 'calendar, tree, form', + 'res_model': 'crm.meeting', + 'type': 'ir.actions.act_window', 'search_view_id': search_view['res_id'] } return value @@ -515,7 +515,7 @@ crm_meeting_generic_wizard() class res_users(osv.osv): _inherit = 'res.users' - + def _get_user_avail(self, cr, uid, ids, name, args, context=None): res={} if not context or not context.get('model'): @@ -533,7 +533,7 @@ class res_users(osv.osv): + c.duration * interval '1 hour') as end \ from crm_meeting m \ join crm_case c on (c.id=m.inherit_case_id)\ - where c.user_id = %s + where c.user_id = %s and m.id not in (""" % (datas['id']) + str(context['active_id']) +")") dates = cr.dictfetchall() overlaps = False @@ -546,11 +546,11 @@ class res_users(osv.osv): over = cr.fetchone()[0] if over: overlaps = True - + # check for attendee added already cr.execute("""select att.user_id , c.id - from calendar_attendee att - inner join crm_attendee_rel rel on (rel.attendee_id=att.id) + from calendar_attendee att + inner join crm_attendee_rel rel on (rel.attendee_id=att.id) join crm_meeting m on (rel.case_id=m.id) join crm_case c on (m.inherit_case_id = c.id ) where (c.date, c.date::timestamp + c.duration * interval '1 hour') overlaps\ @@ -563,7 +563,7 @@ class res_users(osv.osv): else: res[id] = 'free' return res - + _columns = { 'availability': fields.function(_get_user_avail, type='selection', \ selection=[('free', 'Free'), ('busy', 'Busy')], \ diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index 40527dcb017..c2bbf77e19f 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -34,16 +34,16 @@ class crm_phonecall(osv.osv): _name = "crm.phonecall" _description = "Phonecall Cases" _order = "id desc" - _inherits = {'crm.case':"inherit_case_id"} - _columns = { + _inherits = {'crm.case':"inherit_case_id"} + _columns = { 'inherit_case_id': fields.many2one('crm.case','Case',ondelete='cascade'), } - + def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: - select = ids + select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: @@ -64,25 +64,25 @@ class crm_phonecall(osv.osv): def onchange_categ_id(self, cr, uid, ids, *args, **argv): return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv) def case_close(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_close',cr,uid,ids,*args,**argv) + return self._map_ids('case_close',cr,uid,ids,*args,**argv) def case_open(self,cr, uid, ids, *args, **argv): return self._map_ids('case_open',cr,uid,ids,*args,**argv) def case_cancel(self,cr, uid, ids, *args, **argv): return self._map_ids('case_cancel',cr,uid,ids,*args,**argv) def case_reset(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_reset',cr,uid,ids,*args,**argv) - def case_escalate(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) - def case_pending(self,cr, uid, ids, *args, **argv): + return self._map_ids('case_reset',cr,uid,ids,*args,**argv) + def case_escalate(self,cr, uid, ids, *args, **argv): + return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) + def case_pending(self,cr, uid, ids, *args, **argv): return self._map_ids('case_pending',cr,uid,ids,*args,**argv) - def msg_new(self, cr, uid, msg): + def msg_new(self, cr, uid, msg): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { - 'name': msg['Subject'], + 'name': msg['Subject'], 'email_from': msg['From'], - 'email_cc': msg['Cc'], + 'email_cc': msg['Cc'], 'user_id': False, 'description': msg_body['body'], 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], @@ -90,16 +90,16 @@ class crm_phonecall(osv.osv): res = mailgate_obj.partner_get(cr, uid, msg['From']) if res: data.update(res) - res = self.create(cr, uid, data) + res = self.create(cr, uid, data) return res def msg_update(self, cr, uid, ids, *args, **argv): return self._map_ids('msg_update',cr, uid, ids, *args, **argv) def emails_get(self, cr, uid, ids, *args, **argv): return self._map_ids('emails_get',cr, uid, ids, *args, **argv) - def msg_send(self, cr, uid, ids, *args, **argv): - return self._map_ids('msg_send',cr, uid, ids, *args, **argv) - + def msg_send(self, cr, uid, ids, *args, **argv): + return self._map_ids('msg_send',cr, uid, ids, *args, **argv) + crm_phonecall() @@ -107,7 +107,7 @@ class crm_phonecall_assign_wizard(osv.osv_memory): _name = 'crm.phonecall.assign_wizard' _columns = { - 'section_id': fields.many2one('crm.case.section', 'Section', required=True), + 'section_id': fields.many2one('crm.case.section', 'Section', required=False), 'user_id': fields.many2one('res.users', 'Responsible'), } @@ -137,17 +137,17 @@ class crm_phonecall_assign_wizard(osv.osv_memory): 'section_id':res.get('section_id',False), 'user_id':res.get('user_id',False), 'case_id' : case.inherit_case_id.id - }, context=context) + }, context=context) case_obj.case_close(cr, uid, [case_id]) data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter') search_view = data_obj.read(cr, uid, result, ['res_id']) - value = { + value = { 'name': _('Phone Calls'), 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'crm.phonecall', - 'res_id': int(new_case_id), + 'res_id': int(new_case_id), 'type': 'ir.actions.act_window', 'search_view_id': search_view['res_id'] } diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index 2ad03e93263..4a5016108ac 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -3,7 +3,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -78,7 +78,7 @@ tree - + @@ -624,5 +624,31 @@ + + + view.users.form.crm.modif.inherited1 + res.users + + form + + + + + + + + + view.users.form.crm.modif.inherited2 + res.users + form + + + + + + + + + diff --git a/addons/crm/security/crm_security.xml b/addons/crm/security/crm_security.xml index a097147fec2..73951681fb7 100644 --- a/addons/crm/security/crm_security.xml +++ b/addons/crm/security/crm_security.xml @@ -18,5 +18,130 @@ + + + crm.meeting.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.claim.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.fundraising.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.helpdesk.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.meeting.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.leads.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.opportunities.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.phone.calls.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + + + crm.case.rule + + + + + + = + user.section_id.id + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + diff --git a/addons/crm_project/__terp__.py b/addons/crm_project/__terp__.py index 0d4c71a548d..e4c0ef2adcc 100644 --- a/addons/crm_project/__terp__.py +++ b/addons/crm_project/__terp__.py @@ -39,6 +39,7 @@ 'crm_bugs_menu.xml', 'crm_feature_view.xml', 'crm_feature_menu.xml', + 'security/crm_project_security.xml' ], 'demo_xml': ['crm_bugs_demo.xml'], 'installable': True, diff --git a/addons/crm_project/crm_project_bug.py b/addons/crm_project/crm_project_bug.py index 997980181c0..ecc1167372a 100644 --- a/addons/crm_project/crm_project_bug.py +++ b/addons/crm_project/crm_project_bug.py @@ -36,17 +36,24 @@ class crm_project_bug(osv.osv): _name = "crm.project.bug" _description = "Project Bug Cases" _order = "id desc" - _inherits = {'crm.case':"inherit_case_id"} - _columns = { + _inherits = {'crm.case':"inherit_case_id"} + _columns = { 'inherit_case_id':fields.many2one('crm.case','Case'), 'project_id':fields.many2one('project.project', 'Project'), } - + + def _get_project(self, cr, uid, context): + user = self.pool.get('res.users').browse(cr, uid, uid) + return user.project_id.id + + _defaults = { + 'project_id':_get_project + } def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: - select = ids + select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: @@ -69,25 +76,25 @@ class crm_project_bug(osv.osv): def onchange_categ_id(self, cr, uid, ids, *args, **argv): return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv) def case_close(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_close',cr,uid,ids,*args,**argv) + return self._map_ids('case_close',cr,uid,ids,*args,**argv) def case_open(self,cr, uid, ids, *args, **argv): return self._map_ids('case_open',cr,uid,ids,*args,**argv) def case_cancel(self,cr, uid, ids, *args, **argv): return self._map_ids('case_cancel',cr,uid,ids,*args,**argv) def case_reset(self,cr, uid, ids, *args, **argv): return self._map_ids('case_reset',cr,uid,ids,*args,**argv) - def case_escalate(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) - def case_pending(self,cr, uid, ids, *args, **argv): + def case_escalate(self,cr, uid, ids, *args, **argv): + return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) + def case_pending(self,cr, uid, ids, *args, **argv): return self._map_ids('case_pending',cr,uid,ids,*args,**argv) - def msg_new(self, cr, uid, msg): + def msg_new(self, cr, uid, msg): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { - 'name': msg['Subject'], + 'name': msg['Subject'], 'email_from': msg['From'], - 'email_cc': msg['Cc'], + 'email_cc': msg['Cc'], 'user_id': False, 'description': msg_body['body'], 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], @@ -95,16 +102,16 @@ class crm_project_bug(osv.osv): res = mailgate_obj.partner_get(cr, uid, msg['From']) if res: data.update(res) - res = self.create(cr, uid, data) + res = self.create(cr, uid, data) return res def msg_update(self, cr, uid, ids, *args, **argv): return self._map_ids('msg_update',cr, uid, ids, *args, **argv) def emails_get(self, cr, uid, ids, *args, **argv): return self._map_ids('emails_get',cr, uid, ids, *args, **argv) - def msg_send(self, cr, uid, ids, *args, **argv): - return self._map_ids('msg_send',cr, uid, ids, *args, **argv) - + def msg_send(self, cr, uid, ids, *args, **argv): + return self._map_ids('msg_send',cr, uid, ids, *args, **argv) + crm_project_bug() @@ -143,20 +150,20 @@ class crm_bug_assign_wizard(osv.osv_memory): 'section_id':res.get('section_id',False), 'user_id':res.get('user_id',False), 'case_id' : case.inherit_case_id.id - }, context=context) + }, context=context) case_obj.case_close(cr, uid, [case_id]) data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'crm_project', 'view_crm_case_bugs_filter') search_view = data_obj.read(cr, uid, result, ['res_id']) - value = { + value = { 'name': _('Bugs'), 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'crm.project.bug', - 'res_id': int(new_case_id), - 'type': 'ir.actions.act_window', - 'search_view_id': search_view['res_id'] + 'res_id': int(new_case_id), + 'type': 'ir.actions.act_window', + 'search_view_id': search_view['res_id'] } return value diff --git a/addons/crm_project/crm_project_feature.py b/addons/crm_project/crm_project_feature.py index c0333c8a921..dbf04814057 100644 --- a/addons/crm_project/crm_project_feature.py +++ b/addons/crm_project/crm_project_feature.py @@ -36,17 +36,22 @@ class crm_project_future_request(osv.osv): _name = "crm.project.future" _description = "Project Future Request" _order = "id desc" - _inherits = {'crm.case':"inherit_case_id"} - _columns = { + _inherits = {'crm.case':"inherit_case_id"} + _columns = { 'inherit_case_id':fields.many2one('crm.case','Case'), 'project_id':fields.many2one('project.project', 'Project'), } - + def _get_project(self, cr, uid, context): + user = self.pool.get('res.users').browse(cr,uid,uid) + return user.project_id.id + _defaults = { + 'project_id':_get_project + } def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: - select = ids + select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: @@ -69,25 +74,25 @@ class crm_project_future_request(osv.osv): def onchange_categ_id(self, cr, uid, ids, *args, **argv): return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv) def case_close(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_close',cr,uid,ids,*args,**argv) + return self._map_ids('case_close',cr,uid,ids,*args,**argv) def case_open(self,cr, uid, ids, *args, **argv): return self._map_ids('case_open',cr,uid,ids,*args,**argv) def case_cancel(self,cr, uid, ids, *args, **argv): return self._map_ids('case_cancel',cr,uid,ids,*args,**argv) def case_reset(self,cr, uid, ids, *args, **argv): return self._map_ids('case_reset',cr,uid,ids,*args,**argv) - def case_escalate(self,cr, uid, ids, *args, **argv): - return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) - def case_pending(self,cr, uid, ids, *args, **argv): + def case_escalate(self,cr, uid, ids, *args, **argv): + return self._map_ids('case_escalate',cr,uid,ids,*args,**argv) + def case_pending(self,cr, uid, ids, *args, **argv): return self._map_ids('case_pending',cr,uid,ids,*args,**argv) - def msg_new(self, cr, uid, msg): + def msg_new(self, cr, uid, msg): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { - 'name': msg['Subject'], + 'name': msg['Subject'], 'email_from': msg['From'], - 'email_cc': msg['Cc'], + 'email_cc': msg['Cc'], 'user_id': False, 'description': msg_body['body'], 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })], @@ -95,15 +100,15 @@ class crm_project_future_request(osv.osv): res = mailgate_obj.partner_get(cr, uid, msg['From']) if res: data.update(res) - res = self.create(cr, uid, data) + res = self.create(cr, uid, data) return res def msg_update(self, cr, uid, ids, *args, **argv): return self._map_ids('msg_update',cr, uid, ids, *args, **argv) def emails_get(self, cr, uid, ids, *args, **argv): return self._map_ids('emails_get',cr, uid, ids, *args, **argv) - def msg_send(self, cr, uid, ids, *args, **argv): - return self._map_ids('msg_send',cr, uid, ids, *args, **argv) + def msg_send(self, cr, uid, ids, *args, **argv): + return self._map_ids('msg_send',cr, uid, ids, *args, **argv) crm_project_future_request() @@ -142,20 +147,20 @@ class crm_future_request_assign_wizard(osv.osv_memory): 'section_id':res.get('section_id',False), 'user_id':res.get('user_id',False), 'case_id' : case.inherit_case_id.id - }, context=context) + }, context=context) case_obj.case_close(cr, uid, [case_id]) data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'crm_project', 'view_crm_case_future_filter') search_view = data_obj.read(cr, uid, result, ['res_id']) - value = { + value = { 'name': _('Future Requests'), 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'crm.project.future', - 'res_id': int(new_case_id), - 'type': 'ir.actions.act_window', - 'search_view_id': search_view['res_id'] + 'res_id': int(new_case_id), + 'type': 'ir.actions.act_window', + 'search_view_id': search_view['res_id'] } return value diff --git a/addons/crm_project/security/crm_project_security.xml b/addons/crm_project/security/crm_project_security.xml new file mode 100644 index 00000000000..85ff137e177 --- /dev/null +++ b/addons/crm_project/security/crm_project_security.xml @@ -0,0 +1,34 @@ + + + + + + + + crm.project.bug.rule.group + + + + + + = + user.project_id.id + ['|',('project_id','=',False),('project_id','=',[user.project_id.id])] + + + + + crm.project.feature.rule.group + + + + + + = + user.project_id.id + ['|',('project_id','=',False),('project_id','=',[user.project_id.id])] + + + + + diff --git a/addons/project/project.py b/addons/project/project.py index d47f92dbb42..4567ba1c4b0 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -61,7 +61,7 @@ class project(osv.osv): cr.execute('''SELECT project_id, sum(planned_hours), sum(total_hours), sum(effective_hours) FROM - project_task + project_task WHERE project_id in ('''+','.join(map(str,ids2))+''') AND state<>'cancelled' @@ -137,7 +137,7 @@ class project(osv.osv): # toggle activity of projects, their sub projects and their tasks def set_template(self, cr, uid, ids, context={}): - res = self.setActive(cr, uid, ids, value=False, context=context) + res = self.setActive(cr, uid, ids, value=False, context=context) return res def set_done(self, cr, uid, ids, context={}): @@ -192,17 +192,17 @@ class project(osv.osv): raise osv.except_osv(_('Operation Done'), _('A new project has been created !\nWe suggest you to close this one and work on this new project.')) # set active value for a project, its sub projects and its tasks - def setActive(self, cr, uid, ids, value=True, context={}): - for proj in self.browse(cr, uid, ids, context): + def setActive(self, cr, uid, ids, value=True, context={}): + for proj in self.browse(cr, uid, ids, context): self.write(cr, uid, [proj.id], {'state': value and 'open' or 'template'}, context) cr.execute('select id from project_task where project_id=%s', (proj.id,)) tasks_id = [x[0] for x in cr.fetchall()] if tasks_id: self.pool.get('project.task').write(cr, uid, tasks_id, {'active': value}, context) - cr.execute('select id from project_project where parent_id=%s', (proj.id,)) - project_ids = [x[0] for x in cr.fetchall()] + cr.execute('select id from project_project where parent_id=%s', (proj.id,)) + project_ids = [x[0] for x in cr.fetchall()] for child in project_ids: - self.setActive(cr, uid, [child], value, context) + self.setActive(cr, uid, [child], value, context) return True project() @@ -269,7 +269,7 @@ class task(osv.osv): #_sql_constraints = [ # ('remaining_hours', 'CHECK (remaining_hours>=0)', 'Please increase and review remaining hours ! It can not be smaller than 0.'), #] - + def copy_data(self, cr, uid, id, default={},context={}): default = default or {} default['work_ids'] = [] @@ -318,7 +318,7 @@ class task(osv.osv): 'active': lambda *a: True, 'date_start': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), 'project_id': _default_project, - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c) + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c) } _order = "sequence, priority, date_deadline, id" @@ -335,22 +335,22 @@ class task(osv.osv): return res eview = etree.fromstring(res['arch']) - + def _check_rec(eview): if eview.attrib.get('widget','') == 'float_time': eview.set('widget','float') for child in eview: _check_rec(child) return True - + _check_rec(eview) - + res['arch'] = etree.tostring(eview) - + for f in res['fields']: if 'Hours' in res['fields'][f]['string']: res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm) - + return res def do_close(self, cr, uid, ids, *args): @@ -485,7 +485,7 @@ class config_compute_remaining(osv.osv_memory): _defaults = { 'remaining_hours': _get_remaining } - + def compute_hours(self, cr, uid, ids, context=None): if 'active_id' in context: remaining_hrs=self.browse(cr,uid,ids)[0].remaining_hours @@ -495,5 +495,24 @@ class config_compute_remaining(osv.osv_memory): } config_compute_remaining() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +class message(osv.osv): + _name = "project.message" + _description = "Message" + _columns = { + 'subject': fields.char('Subject', size=128), + 'description': fields.char('Description', size =128), + 'project_id': fields.many2one('project.project', 'Project', ondelete='cascade'), + 'date': fields.date('Date'), + 'user_id': fields.many2one('res.users', 'User'), + } +message() +class users(osv.osv): + _inherit = 'res.users' + _description ="User" + _columns = { + 'project_id': fields.many2one('project.project', 'Project'), + } + +users() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index d074da533bf..3b4eee97adc 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -484,7 +484,6 @@ tree,form,calendar,gantt,graph - @@ -560,7 +559,7 @@ [('state','=','open')] - +menu_main Unassigned Tasks project.task @@ -661,9 +660,80 @@ + + + + res.users.project.form1 + res.users + form + + + + + + + + + + + view.users.form.project.modif.inherited1 + res.users + + form + + + + + + + + + + project.message.form + project.message + form + +
+ + + + + + + +
+
+
+ + + project.message.form + project.message + tree + + + + + + + + + + + + + Messages + project.message + form + tree,form + + + + + + - + \ No newline at end of file diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index 779ec43bc24..8c1be345402 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -36,5 +36,60 @@ + + + + project.task.rule.group + + + + + + = + user.project_id.id + ['|',('project_id','=',False),('project_id','=',[user.project_id.id])] + + + + + project.task.work.rule.group + + + + + + = + user.project_id.id + ['|',('task_id.project_id','=',False),('task_id.project_id','=',[user.project_id.id])] + + + + + project.project.work.rule.group + + + + + + = + user.project_id.id + ['|',('id','=',False),('id','=',[user.project_id.id])] + + + + + project.project.work.rule.group + + + + + + = + user.project_id.id + ['|',('project_id','=',False),('project_id','=',[user.project_id.id])] + + + + diff --git a/addons/sale_crm/__terp__.py b/addons/sale_crm/__terp__.py index 26b50e586e8..c1b59468ce5 100644 --- a/addons/sale_crm/__terp__.py +++ b/addons/sale_crm/__terp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -38,7 +38,11 @@ crm modules. 'website': 'http://www.openerp.com', 'depends': ['sale', 'crm'], 'init_xml': [], - 'update_xml': ['sale_crm_wizard.xml', 'sale_crm_view.xml', 'process/sale_crm_process.xml'], + 'update_xml': ['sale_crm_wizard.xml', + 'sale_crm_view.xml', + 'process/sale_crm_process.xml', + 'security/sale_crm_security.xml', + ], 'demo_xml': [], 'installable': True, 'active': False, diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py index e01a9f192b9..5972d253025 100644 --- a/addons/sale_crm/sale_crm.py +++ b/addons/sale_crm/sale_crm.py @@ -23,10 +23,19 @@ from osv import osv,fields class sale_order(osv.osv): _inherit = 'sale.order' + _description = 'Sale orders' _columns = { 'section_id': fields.many2one('crm.case.section', 'Section'), - } + } + + def _get_section(self, cr, uid, context): + user = self.pool.get('res.users').browse(cr,uid,uid) + return user.section_id.id + + _defaults = { + 'section_id':_get_section + } + sale_order() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/sale_crm/sale_crm_view.xml b/addons/sale_crm/sale_crm_view.xml index 1b611ca7414..a6f6868dc21 100644 --- a/addons/sale_crm/sale_crm_view.xml +++ b/addons/sale_crm/sale_crm_view.xml @@ -25,7 +25,7 @@ - + diff --git a/addons/sale_crm/security/sale_crm_security.xml b/addons/sale_crm/security/sale_crm_security.xml new file mode 100644 index 00000000000..8bcde374937 --- /dev/null +++ b/addons/sale_crm/security/sale_crm_security.xml @@ -0,0 +1,32 @@ + + + + + + Sale Order sale_crm + + + + + + = + user.section_id.id + + ['|',('section_id','=',False),('section_id','=',[user.section_id.id])] + + + + Sale Order Line sale_crm + + + + + + = + user.section_id.id + + ['|',('order_id.section_id','=',False),('order_id.section_id','=',[user.section_id.id])] + + + +