-
diff --git a/crm_phone/__openerp__.py b/crm_phone/__openerp__.py
index cc2e62e..bd6ea0a 100644
--- a/crm_phone/__openerp__.py
+++ b/crm_phone/__openerp__.py
@@ -24,13 +24,18 @@ for any help or question about this module.
'author': "Akretion,Odoo Community Association (OCA)",
'website': 'http://www.akretion.com/',
'depends': ['base_phone', 'crm'],
+ 'conflicts': ['crm_voip'],
'data': [
+ 'security/phonecall_security.xml',
'security/ir.model.access.csv',
- 'crm_view.xml',
- 'res_users_view.xml',
+ 'view/crm_phonecall.xml',
+ 'view/crm_lead.xml',
+ 'view/res_partner.xml',
+ 'view/res_users.xml',
'wizard/number_not_found_view.xml',
'wizard/create_crm_phonecall_view.xml',
],
+ 'demo': ['demo/crm_phonecall.xml'],
'test': ['test/phonenum.yml'],
'installable': True,
'auto_install': True,
diff --git a/crm_phone/crm_phone.py b/crm_phone/crm_phone.py
index 5723280..53a3c40 100644
--- a/crm_phone/crm_phone.py
+++ b/crm_phone/crm_phone.py
@@ -23,14 +23,11 @@ class CrmLead(models.Model):
vals_reformated = self._reformat_phonenumbers_write(vals)
return super(CrmLead, self).write(vals_reformated)
- def name_get(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- if context.get('callerid'):
+ @api.multi
+ def name_get(self):
+ if self._context.get('callerid'):
res = []
- if isinstance(ids, (int, long)):
- ids = [ids]
- for lead in self.browse(cr, uid, ids, context=context):
+ for lead in self:
if lead.partner_name and lead.contact_name:
name = u'%s (%s)' % (lead.contact_name, lead.partner_name)
elif lead.partner_name:
@@ -42,8 +39,145 @@ class CrmLead(models.Model):
res.append((lead.id, name))
return res
else:
- return super(CrmLead, self).name_get(
- cr, uid, ids, context=context)
+ return super(CrmLead, self).name_get()
+
+ phonecall_ids = fields.One2many(
+ 'crm.phonecall', 'opportunity_id', string='Phone Calls')
+ phonecall_count = fields.Integer(
+ compute='_count_phonecalls', string='Number of Phonecalls',
+ readonly=True)
+
+ @api.multi
+ @api.depends('phonecall_ids')
+ def _count_phonecalls(self):
+ cpo = self.env['crm.phonecall']
+ for lead in self:
+ try:
+ lead.phonecall_count = cpo.search_count(
+ [('opportunity_id', '=', lead.id)])
+ except:
+ lead.phonecall_count = 0
+
+
+class CrmPhonecall(models.Model):
+ _name = 'crm.phonecall'
+ _inherit = ['phone.common', 'mail.thread']
+ _order = "id desc"
+ _phone_fields = ['partner_phone', 'partner_mobile']
+ _country_field = None
+ _partner_field = 'partner_id'
+
+ # Restore the object that existed in v8
+ # and doesn't exist in v9 community any more
+ name = fields.Char(
+ string='Call Summary', required=True, track_visibility='onchange')
+ date = fields.Datetime(
+ string='Date', track_visibility='onchange', copy=False,
+ default=lambda self: fields.Datetime.now())
+ description = fields.Text(string='Description', copy=False)
+ company_id = fields.Many2one(
+ 'res.company', string='Company',
+ default=lambda self: self.env['res.company']._company_default_get(
+ 'crm.phonecall'))
+ user_id = fields.Many2one(
+ 'res.users', string='Responsible', track_visibility='onchange',
+ default=lambda self: self.env.user)
+ team_id = fields.Many2one(
+ 'crm.team', string='Sales Team', track_visibility='onchange',
+ default=lambda self: self.env['crm.team']._get_default_team_id())
+ partner_id = fields.Many2one(
+ 'res.partner', string='Contact', ondelete='cascade')
+ partner_phone = fields.Char(string='Phone')
+ partner_mobile = fields.Char(string='Mobile')
+ priority = fields.Selection([
+ ('0', 'Low'),
+ ('1', 'Normal'),
+ ('2', 'High')
+ ], string='Priority', track_visibility='onchange', default='1')
+ opportunity_id = fields.Many2one(
+ 'crm.lead', string='Lead/Opportunity',
+ ondelete='cascade', track_visibility='onchange')
+ state = fields.Selection([
+ ('open', 'To Do'),
+ ('done', 'Held'),
+ ('cancel', 'Cancelled'),
+ ], string='Status', default='open', copy=False, required=True,
+ track_visibility='onchange',
+ help='The status is set to Confirmed, when a case is created.\n'
+ 'When the call is over, the status is set to Held.\n'
+ 'If the call is not applicable anymore, the status can be set to '
+ 'Cancelled.')
+ direction = fields.Selection([
+ ('inbound', 'Inbound'),
+ ('outbound', 'Outbound'),
+ ], string='Type', required=True, default='outbound')
+
+ @api.model
+ def create(self, vals):
+ vals_reformated = self._reformat_phonenumbers_create(vals)
+ return super(CrmPhonecall, self).create(vals_reformated)
+
+ @api.multi
+ def write(self, vals):
+ vals_reformated = self._reformat_phonenumbers_write(vals)
+ return super(CrmPhonecall, self).write(vals_reformated)
+
+ @api.onchange('partner_id')
+ def onchange_partner_id(self):
+ if self.partner_id:
+ self.partner_phone = self.partner_id.phone
+ self.partner_mobile = self.partner_id.mobile
+
+ @api.onchange('opportunity_id')
+ def onchange_opportunity_id(self):
+ if self.opportunity_id:
+ self.partner_phone = self.opportunity_id.phone
+ self.partner_mobile = self.opportunity_id.mobile
+ self.team_id = self.opportunity_id.team_id.id
+ self.partner_id = self.opportunity_id.partner_id.id
+
+ @api.multi
+ def schedule_another_call(self):
+ self.ensure_one()
+ cur_call = self[0]
+ ctx = self._context.copy()
+ ctx.update({
+ 'default_date': False,
+ 'default_partner_id': cur_call.partner_id.id,
+ 'default_opportunity_id': cur_call.opportunity_id.id,
+ 'default_direction': 'outbound',
+ 'default_partner_phone': cur_call.partner_phone,
+ 'default_partner_mobile': cur_call.partner_mobile,
+ })
+ action = {
+ 'name': _('Phone Call'),
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'crm.phonecall',
+ 'view_mode': 'form,tree,calendar',
+ 'context': ctx,
+ }
+ return action
+
+
+class ResPartner(models.Model):
+ _inherit = 'res.partner'
+
+ phonecall_ids = fields.One2many(
+ 'crm.phonecall', 'partner_id', string='Phone Calls')
+ phonecall_count = fields.Integer(
+ compute='_count_phonecalls', string='Number of Phonecalls',
+ readonly=True)
+
+ @api.multi
+ @api.depends('phonecall_ids')
+ def _count_phonecalls(self):
+ cpo = self.env['crm.phonecall']
+ for partner in self:
+ try:
+ partner.phonecall_count = cpo.search_count(
+ [('partner_id', 'child_of', partner.id)])
+ except:
+ partner.phonecall_count = 0
class ResUsers(models.Model):
diff --git a/crm_phone/demo/crm_phonecall.xml b/crm_phone/demo/crm_phonecall.xml
new file mode 100644
index 0000000..6b79553
--- /dev/null
+++ b/crm_phone/demo/crm_phonecall.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+ Presentation of new product line
+ done
+ +33442127812
+ outbound
+
+
+
+
+
+
+ Close the deal
+ open
+ +33543137913
+ outbound
+
+
+
+
+
+
+ Lobby about our offer
+ open
+ +33543137914
+ outbound
+
+
+
+
+
+
+ Remote Demo of the software
+ open
+ +33789320421
+ outbound
+
+
+
+
+
+
+ Asked training program
+ done
+ +33389320442
+ inbound
+
+
+
+
+
+
diff --git a/crm_phone/security/ir.model.access.csv b/crm_phone/security/ir.model.access.csv
index 1dbae56..826e898 100644
--- a/crm_phone/security/ir.model.access.csv
+++ b/crm_phone/security/ir.model.access.csv
@@ -1,2 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
callerid_crm_lead_read,Read access on crm.lead,crm.model_crm_lead,base_phone.group_callerid,1,0,0,0
+access_crm_phonecall_partner_manager,Full access on crm.phonecall to Contact mgr,model_crm_phonecall,base.group_partner_manager,1,1,1,1
+access_crm_phonecall_sale_manager,Full access on crm.phonecall to Sale mgr,model_crm_phonecall,base.group_sale_manager,1,1,1,1
+access_crm_phonecall_sale_user,Read/Write/Create access on crm.phonecall to Sale users,model_crm_phonecall,base.group_sale_salesman,1,1,1,0
diff --git a/crm_phone/security/phonecall_security.xml b/crm_phone/security/phonecall_security.xml
new file mode 100644
index 0000000..42f5554
--- /dev/null
+++ b/crm_phone/security/phonecall_security.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Personal Phone Calls
+
+
+ ['|', ('user_id', '=', False), ('user_id', '=', user.id)]
+
+
+
+ All Phone Calls
+
+
+ [(1, '=', 1)]
+
+
+
+ Multi-company Phone Calls
+
+ ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]
+
+
+
+
+
diff --git a/crm_phone/crm_view.xml b/crm_phone/view/crm_lead.xml
similarity index 67%
rename from crm_phone/crm_view.xml
rename to crm_phone/view/crm_lead.xml
index 48fe17a..4c1948e 100644
--- a/crm_phone/crm_view.xml
+++ b/crm_phone/view/crm_lead.xml
@@ -19,6 +19,14 @@
fax
+
+
+
@@ -44,6 +52,14 @@
fax
+
+
+
diff --git a/crm_phone/view/crm_phonecall.xml b/crm_phone/view/crm_phonecall.xml
new file mode 100644
index 0000000..9d538b9
--- /dev/null
+++ b/crm_phone/view/crm_phonecall.xml
@@ -0,0 +1,160 @@
+
+
+
+
+
+
+
+
+ crm.phonecall.form
+ crm.phonecall
+
+
+
+
+
+
+ crm.phonecall.tree
+ crm.phonecall
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ crm.phonecall.calendar
+ crm.phonecall
+
+
+
+
+
+
+
+
+
+ crm.phonecall.search
+ crm.phonecall
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Phone Calls
+ crm.phonecall
+ tree,calendar,form
+
+
+
+ Logged Calls
+ crm.phonecall
+ tree,calendar,form
+ {'search_default_done': 1, 'default_state': 'done'}
+
+
+
+
+
+ Scheduled Calls
+ crm.phonecall
+ tree,calendar,form
+ {'search_default_open': 1, 'default_state': 'open'}
+
+
+
+
+
+
+
diff --git a/crm_phone/view/res_partner.xml b/crm_phone/view/res_partner.xml
new file mode 100644
index 0000000..840a64a
--- /dev/null
+++ b/crm_phone/view/res_partner.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+ phonecall.res.partner.form
+ res.partner
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/crm_phone/res_users_view.xml b/crm_phone/view/res_users.xml
similarity index 100%
rename from crm_phone/res_users_view.xml
rename to crm_phone/view/res_users.xml
diff --git a/crm_phone/wizard/create_crm_phonecall.py b/crm_phone/wizard/create_crm_phonecall.py
index 45570c8..733ffad 100644
--- a/crm_phone/wizard/create_crm_phonecall.py
+++ b/crm_phone/wizard/create_crm_phonecall.py
@@ -6,33 +6,28 @@ from openerp import models, api, _
import phonenumbers
-# TODO : crm.phonecall : doesn't exist any more... what is the replacement ?
-
class WizardCreateCrmPhonecall(models.TransientModel):
_name = "wizard.create.crm.phonecall"
@api.multi
def button_create_outgoing_phonecall(self):
self.ensure_one()
- return self._create_open_crm_phonecall(crm_categ='Outbound')
+ return self._create_open_crm_phonecall('outbound')
@api.model
- def _create_open_crm_phonecall(self, crm_categ):
- categ = self.with_context(lang='en_US').env['crm.case.categ'].search(
- [('name', '=', crm_categ)])
- case_section = self.env['crm.case.section'].search(
+ def _create_open_crm_phonecall(self, direction='outbound'):
+ teams = self.env['crm.team'].search(
[('member_ids', 'in', self._uid)])
action_ctx = self.env.context.copy()
action_ctx.update({
- 'default_categ_id': categ and categ[0].id or False,
- 'default_section_id':
- case_section and case_section[0].id or False,
+ 'default_direction': direction,
+ 'default_team_id': teams and teams[0].id or False,
})
domain = False
if self.env.context.get('click2dial_model') == 'res.partner':
partner_id = self.env.context.get('click2dial_id')
action_ctx['default_partner_id'] = partner_id
- domain = [('partner_id', '=', partner_id)]
+ domain = [('partner_id', 'child_of', partner_id)]
elif self.env.context.get('click2dial_model') == 'crm.lead':
lead_id = self.env.context.get('click2dial_id')
action_ctx['default_opportunity_id'] = lead_id
@@ -50,7 +45,7 @@ class WizardCreateCrmPhonecall(models.TransientModel):
'type': 'ir.actions.act_window',
'res_model': 'crm.phonecall',
'domain': domain,
- 'view_mode': 'form,tree',
+ 'view_mode': 'form,tree,calendar',
'nodestroy': False, # close the pop-up wizard after action
'target': 'current',
'context': action_ctx,
diff --git a/crm_phone/wizard/number_not_found_view.xml b/crm_phone/wizard/number_not_found_view.xml
index dcc52a2..0b685b8 100644
--- a/crm_phone/wizard/number_not_found_view.xml
+++ b/crm_phone/wizard/number_not_found_view.xml
@@ -16,14 +16,16 @@
+ string="Create Lead with this Number" type="object"
+ class="oe_highlight"/>
+ string="Update Lead with this Number" type="object"
+ class="oe_highlight"/>
diff --git a/hr_phone/security/ir.model.access.csv b/hr_phone/security/ir.model.access.csv
index 610ef29..91ef95d 100644
--- a/hr_phone/security/ir.model.access.csv
+++ b/hr_phone/security/ir.model.access.csv
@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
callerid_hr_employee_read,Read access on hr.employee,hr.model_hr_employee,base_phone.group_callerid,1,0,0,0
+callerid_resource_resource_read,Read access on resource.resource,resource.model_resource_resource,base_phone.group_callerid,1,0,0,0
diff --git a/hr_recruitment_phone/hr_recruitment_phone.py b/hr_recruitment_phone/hr_recruitment_phone.py
index 131516e..815c8ac 100644
--- a/hr_recruitment_phone/hr_recruitment_phone.py
+++ b/hr_recruitment_phone/hr_recruitment_phone.py
@@ -22,3 +22,19 @@ class HrApplicant(models.Model):
def write(self, vals):
vals_reformated = self._reformat_phonenumbers_write(vals)
return super(HrApplicant, self).write(vals_reformated)
+
+ @api.multi
+ def name_get(self):
+ if self._context.get('callerid'):
+ res = []
+ for appl in self:
+ if appl.partner_id:
+ name = u'%s (%s)' % (appl.partner_id.name, appl.name)
+ elif appl.partner_name:
+ name = u'%s (%s)' % (appl.partner_name, appl.name)
+ else:
+ name = appl.name
+ res.append((appl.id, name))
+ return res
+ else:
+ return super(HrApplicant, self).name_get()