X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Fcrm%2Fcrm.py;h=b45b8ea871222e831318b667d69b4b3881f06f37;hb=0a22166f88ec8415dbdff8a4e31961e6355d5b9c;hp=1a2f0716abe2a7f40bcffa93f7b370cb802e2b8e;hpb=2bf0978994c88ebf6a382a7b180350ee7ac5e1a9;p=odoo%2Fodoo.git diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 1a2f071..b45b8ea 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -112,7 +112,7 @@ class crm_case_section(osv.osv): 'active': fields.boolean('Active', help="If the active field is set to "\ "true, it will allow you to hide the sales team without removing it."), 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"), - 'change_responsible': fields.boolean('Reassign Escalated', help="When escalating to this team override the saleman with the team leader."), + 'change_responsible': fields.boolean('Reassign Escalated', help="When escalating to this team override the salesman with the team leader."), 'user_id': fields.many2one('res.users', 'Team Leader'), 'member_ids':fields.many2many('res.users', 'sale_member_rel', 'section_id', 'member_id', 'Team Members'), 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by OpenERP about cases in this sales team"), @@ -122,9 +122,9 @@ class crm_case_section(osv.osv): 'note': fields.text('Description'), 'working_hours': fields.float('Working Hours', digits=(16,2 )), 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="restrict", required=True, - help="This Unique Mail Box Alias of the Sales Team allows to manage the Seamless email communication between Mail Box and OpenERP," - "This Alias MailBox also create and Manage the new Email Leads for this Sales Team and also manage the existing Lead email communication."), + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, + help="The email address associated with this team. New emails received will automatically " + "create new leads assigned to the team."), } def _get_stage_common(self, cr, uid, context): @@ -132,9 +132,10 @@ class crm_case_section(osv.osv): return ids _defaults = { - 'active': lambda *a: 1, - 'allow_unlink': lambda *a: 1, - 'stage_ids': _get_stage_common + 'active': 1, + 'allow_unlink': 1, + 'stage_ids': _get_stage_common, + 'alias_domain': False, # always hide alias during creation } _sql_constraints = [ @@ -162,16 +163,24 @@ class crm_case_section(osv.osv): return res def create(self, cr, uid, vals, context=None): - alias_pool = self.pool.get('mail.alias') + mail_alias = self.pool.get('mail.alias') if not vals.get('alias_id'): - name = vals.get('alias_name') or vals['name'] - alias_id = alias_pool.create_unique_alias(cr, uid, - {'alias_name': "sales_team_"+name, - 'alias_model_id': self._name}, context=context) - alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context) - vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']}) + vals.pop('alias_name', None) # prevent errors during copy() + alias_id = mail_alias.create_unique_alias(cr, uid, + {'alias_name': vals['name']}, + model_name="crm.lead", + context=context) + vals['alias_id'] = alias_id res = super(crm_case_section, self).create(cr, uid, vals, context) - alias_pool.write(cr, uid, [vals['alias_id']],{'alias_defaults':{'section_id': res,'type':'lead'}},context) + mail_alias.write(cr, uid, [vals['alias_id']], {'alias_defaults': {'section_id': res, 'type':'lead'}}, context) + return res + + def unlink(self, cr, uid, ids, context=None): + # Cascade-delete mail aliases as well, as they should not exist without the sales team. + mail_alias = self.pool.get('mail.alias') + alias_ids = [team.alias_id.id for team in self.browse(cr, uid, ids, context=context) if team.alias_id ] + res = super(crm_case_section, self).unlink(cr, uid, ids, context=context) + mail_alias.unlink(cr, uid, alias_ids, context=context) return res class crm_case_categ(osv.osv): @@ -212,4 +221,13 @@ def _links_get(self, cr, uid, context=None): res = obj.read(cr, uid, ids, ['object', 'name'], context) return [(r['object'], r['name']) for r in res] +class crm_payment_mode(osv.osv): + """ Payment Mode for Fund """ + _name = "crm.payment.mode" + _description = "CRM Payment Mode" + _columns = { + 'name': fields.char('Name', size=64, required=True), + 'section_id': fields.many2one('crm.case.section', 'Sales Team'), + } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: