+
+
diff --git a/addons/mail/views/res_partner_views.xml b/addons/mail/views/res_partner_views.xml
index daaabf92657..b2cfa6ef131 100644
--- a/addons/mail/views/res_partner_views.xml
+++ b/addons/mail/views/res_partner_views.xml
@@ -31,6 +31,19 @@
+
+
+
+
+
+
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 951b8a2b6b0..c58d86668d1 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -293,6 +293,7 @@ class MailComposer(models.TransientModel):
'record_name': self.record_name,
'no_auto_thread': self.no_auto_thread,
'mail_server_id': self.mail_server_id.id,
+ 'mail_activity_type_id': self.mail_activity_type_id.id,
}
# mass mailing: rendering override wizard static values
if mass_mail_mode and self.model:
From 4aa3f3f94eb094e18d7b381e0d0cdff0cc10ffb9 Mon Sep 17 00:00:00 2001
From: Ravi Gadhia
Date: Mon, 21 Nov 2016 11:32:39 +0100
Subject: [PATCH 05/15] [IMP] account: add support of activities
account.invoice model now supports activities. Filters have been added to ease
their management.
---
addons/account/models/account_invoice.py | 2 +-
addons/account/views/account_invoice_view.xml | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py
index 230d3e5df90..fe48cb54d1c 100644
--- a/addons/account/models/account_invoice.py
+++ b/addons/account/models/account_invoice.py
@@ -37,7 +37,7 @@ MAGIC_COLUMNS = ('id', 'create_uid', 'create_date', 'write_uid', 'write_date')
class AccountInvoice(models.Model):
_name = "account.invoice"
- _inherit = ['mail.thread']
+ _inherit = ['mail.thread', 'mail.activity.mixin']
_description = "Invoice"
_order = "date_invoice desc, number desc, id desc"
diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml
index 40feb8caa75..16e36a1c04c 100644
--- a/addons/account/views/account_invoice_view.xml
+++ b/addons/account/views/account_invoice_view.xml
@@ -335,6 +335,7 @@
+
@@ -523,6 +524,18 @@
+
+
+
+
+
From 87e457158e83295a17761a1ea0d251ba87472596 Mon Sep 17 00:00:00 2001
From: Ravi Gadhia
Date: Mon, 21 Nov 2016 11:33:02 +0100
Subject: [PATCH 06/15] [IMP] crm, website_crm: replace support of activities
crm.lead model now supports activities. Filters have been added to ease
their management. Mail activities replace the old crm.activity model. All code
related to crm.activity is then removed, including views and custom widget.
Standard activities feature is now used widely in Odoo addons and replace
those custom activities.
A small update is required in website_crm_partner_assign. Now the portal user
can only update or create its own activities aka assigned to him. If he has
an activity assigned to him it is displayed in the opportunity website view.
If not editing the opportunity will create a new activity assigned to him.
---
addons/crm/__manifest__.py | 5 +-
addons/crm/data/crm_activity_data.xml | 16 ---
addons/crm/data/crm_activity_demo.xml | 37 -----
addons/crm/data/crm_lead_demo.xml | 132 +++++++++++++-----
addons/crm/data/mail_activity_demo.xml | 24 ++++
addons/crm/models/__init__.py | 1 -
addons/crm/models/crm_activity.py | 50 -------
addons/crm/models/crm_lead.py | 57 +++-----
addons/crm/report/crm_activity_report.py | 6 +-
.../crm/report/crm_activity_report_views.xml | 8 +-
addons/crm/security/ir.model.access.csv | 3 -
addons/crm/static/src/js/tour.js | 16 ++-
addons/crm/tests/test_crm_activity.py | 126 +++++++----------
addons/crm/views/crm_activity_views.xml | 67 ---------
addons/crm/views/crm_lead_views.xml | 88 ++++++------
addons/crm/wizard/__init__.py | 1 -
addons/crm/wizard/crm_activity_log.py | 103 --------------
addons/crm/wizard/crm_activity_log_views.xml | 85 -----------
addons/crm/wizard/crm_lead_to_opportunity.py | 2 +-
addons/mail/static/src/js/activity_log.js | 43 ------
.../static/src/xml/sales_team_dashboard.xml | 8 +-
.../controllers/main.py | 9 +-
.../models/crm_lead.py | 45 +++---
.../security/ir.model.access.csv | 1 -
.../static/src/js/crm_partner_assign.js | 13 +-
.../website_crm_partner_assign_templates.xml | 24 ++--
26 files changed, 304 insertions(+), 666 deletions(-)
delete mode 100644 addons/crm/data/crm_activity_data.xml
delete mode 100644 addons/crm/data/crm_activity_demo.xml
create mode 100644 addons/crm/data/mail_activity_demo.xml
delete mode 100644 addons/crm/models/crm_activity.py
delete mode 100644 addons/crm/views/crm_activity_views.xml
delete mode 100644 addons/crm/wizard/crm_activity_log.py
delete mode 100644 addons/crm/wizard/crm_activity_log_views.xml
delete mode 100644 addons/mail/static/src/js/activity_log.js
diff --git a/addons/crm/__manifest__.py b/addons/crm/__manifest__.py
index b30f5ce5d15..ff62e0ca2a0 100644
--- a/addons/crm/__manifest__.py
+++ b/addons/crm/__manifest__.py
@@ -41,7 +41,6 @@ Dashboard for CRM will include:
'web_tour',
],
'data': [
- 'data/crm_activity_data.xml',
'data/crm_data.xml',
'data/crm_stage_data.xml',
'data/sales_config_settings_data.xml',
@@ -53,7 +52,6 @@ Dashboard for CRM will include:
'security/ir.model.access.csv',
'wizard/base_partner_merge_views.xml',
- 'wizard/crm_activity_log_views.xml',
'wizard/crm_lead_lost_views.xml',
'wizard/crm_lead_to_opportunity_views.xml',
'wizard/crm_merge_opportunities_views.xml',
@@ -64,7 +62,6 @@ Dashboard for CRM will include:
'views/crm_templates.xml',
'views/crm_views.xml',
- 'views/crm_activity_views.xml',
'views/crm_stage_views.xml',
'views/crm_lead_views.xml',
'views/calendar_views.xml',
@@ -74,8 +71,8 @@ Dashboard for CRM will include:
],
'demo': [
'data/crm_demo.xml',
+ 'data/mail_activity_demo.xml',
'data/crm_lead_demo.xml',
- 'data/crm_activity_demo.xml',
'data/base_action_rule_demo.xml',
],
'css': ['static/src/css/crm.css'],
diff --git a/addons/crm/data/crm_activity_data.xml b/addons/crm/data/crm_activity_data.xml
deleted file mode 100644
index cb45e243e97..00000000000
--- a/addons/crm/data/crm_activity_data.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
- Email
-
-
- Call
-
-
- Task
-
-
-
-
diff --git a/addons/crm/data/crm_activity_demo.xml b/addons/crm/data/crm_activity_demo.xml
deleted file mode 100644
index 6c1bb4a25ba..00000000000
--- a/addons/crm/data/crm_activity_demo.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- Follow-up Quote
- Follow-up quote
- 30
-
-
-
- Make Quote
- Send a quotation
- 15
-
-
-
-
- Call for Demo
- 10
- Call for a demo
-
-
-
-
- 5
-
-
-
-
-
- 15
-
-
-
-
-
diff --git a/addons/crm/data/crm_lead_demo.xml b/addons/crm/data/crm_lead_demo.xml
index a4b40a6d984..e0d65f889c8 100644
--- a/addons/crm/data/crm_lead_demo.xml
+++ b/addons/crm/data/crm_lead_demo.xml
@@ -374,9 +374,6 @@ Andrew
]]>
1
-
-
- Meeting to go over pricing information.
@@ -402,9 +399,6 @@ Andrew]]>
2
-
-
- Send Catalog by Email
@@ -427,9 +421,6 @@ Andrew]]>
1
-
-
- Call to get system requirements
@@ -516,9 +507,6 @@ Andrew]]>
2
-
-
- Convert to quote
@@ -542,9 +530,6 @@ Andrew]]>
1
-
-
- Send our service pricelist
@@ -577,9 +562,6 @@ Andrew]]>
1
-
-
- Call to get training needs
@@ -628,9 +610,6 @@ Andrew]]>
1
-
-
- Followup on the proposal
@@ -653,7 +632,6 @@ Andrew]]>
+1 312 349 23242
-
@@ -672,7 +650,6 @@ Andrew]]>
Cannon Hill Park2
-
@@ -691,7 +668,6 @@ Andrew]]>
1
-
@@ -708,8 +684,6 @@ Andrew]]>
0
-
-
@@ -728,8 +702,6 @@ Andrew]]>
Lima0
-
-
@@ -753,9 +725,6 @@ Andrew]]>
C1414CMS Capital Federal2
-
-
- Conf call with technical service
@@ -778,9 +747,6 @@ Andrew]]>
2
-
-
- Send Catalog by Email
@@ -804,9 +770,6 @@ Andrew]]>
2
-
-
- Send Catalog by Email
@@ -817,5 +780,100 @@ Andrew]]>
eval="[ref('crm_case_20'), ref('crm_case_23'), ref('crm_case_27')],
{'install_mode': True}"/>
+
+
+
+
+
+ Meeting to go over pricing information.
+
+
+
+
+
+
+
+ Send Catalog by Email
+
+
+
+
+
+
+ Call to get system requirements
+
+
+
+
+
+
+ Convert to quote
+
+
+
+
+
+
+ Send our service pricelist
+
+
+
+
+
+
+ Call to get training needs
+
+
+
+
+
+
+ Followup on the proposal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Conf call with technical service
+
+
+
+
+
+
+ Send Catalog by Email
+
+
diff --git a/addons/crm/data/mail_activity_demo.xml b/addons/crm/data/mail_activity_demo.xml
new file mode 100644
index 00000000000..320c3b4baf2
--- /dev/null
+++ b/addons/crm/data/mail_activity_demo.xml
@@ -0,0 +1,24 @@
+
+
+
+ Follow-up Quote
+ fa-file-text-o
+
+ Follow-up quote
+ 30
+
+
+ Make Quote
+ fa-file-text-o
+
+ Send a quotation
+ 15
+
+
+ Call for Demo
+ fa-phone
+
+ 10
+ Call for a demo
+
+
diff --git a/addons/crm/models/__init__.py b/addons/crm/models/__init__.py
index 6edf901680d..02caa223da7 100644
--- a/addons/crm/models/__init__.py
+++ b/addons/crm/models/__init__.py
@@ -3,7 +3,6 @@
import res_users
import calendar
-import crm_activity
import crm_lead
import crm_stage
import crm_team
diff --git a/addons/crm/models/crm_activity.py b/addons/crm/models/crm_activity.py
deleted file mode 100644
index 4be550c5564..00000000000
--- a/addons/crm/models/crm_activity.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from odoo import api, fields, models
-
-
-class CrmActivity(models.Model):
- ''' CrmActivity is a model introduced in Odoo v9 that models activities
- performed in CRM, like phone calls, sending emails, making demonstrations,
- ... Users are able to configure their custom activities.
-
- Each activity can configure recommended next activities. This allows to model
- light custom workflows. This way sales manager can configure their crm
- workflow that salepersons will use in their daily job.
-
- CrmActivity inherits from mail.message.subtype. This allows users to follow
- some activities through subtypes. Each activity will generate messages with
- the matching subtypes, allowing reporting and statistics computation based
- on mail.message.subtype model. '''
-
- _name = 'crm.activity'
- _description = 'CRM Activity'
- _inherits = {'mail.message.subtype': 'subtype_id'}
- _rec_name = 'name'
- _order = "sequence"
-
- days = fields.Integer('Number of days', default=0,
- help='Number of days before executing the action, allowing you to plan the date of the action.')
- sequence = fields.Integer('Sequence', default=0)
- team_id = fields.Many2one('crm.team', string='Sales Team')
- subtype_id = fields.Many2one('mail.message.subtype', string='Message Subtype', required=True, ondelete='cascade')
- recommended_activity_ids = fields.Many2many(
- 'crm.activity', 'crm_activity_rel', 'activity_id', 'recommended_id',
- string='Recommended Next Activities')
- preceding_activity_ids = fields.Many2many(
- 'crm.activity', 'crm_activity_rel', 'recommended_id', 'activity_id',
- string='Preceding Activities')
-
- # setting a default value on inherited fields is a bit involved
- res_model = fields.Char('Model', related='subtype_id.res_model', inherited=True, default='crm.lead')
- internal = fields.Boolean('Internal Only', related='subtype_id.internal', inherited=True, default=True)
- default = fields.Boolean('Default', related='subtype_id.default', inherited=True, default=False)
-
- @api.multi
- def unlink(self):
- activities = self.search([('subtype_id', '=', self.subtype_id.id)])
- # to ensure that the subtype is only linked the current activity
- if len(activities) == 1:
- self.subtype_id.unlink()
- return super(CrmActivity, self).unlink()
diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py
index 86651ef22c1..b2ed22ba7d4 100644
--- a/addons/crm/models/crm_lead.py
+++ b/addons/crm/models/crm_lead.py
@@ -52,11 +52,10 @@ CRM_LEAD_FIELDS_TO_MERGE = [
class Lead(FormatAddress, models.Model):
-
_name = "crm.lead"
_description = "Lead/Opportunity"
- _order = "priority desc,date_action,id desc"
- _inherit = ['mail.thread', 'utm.mixin']
+ _order = "priority desc,activity_date_deadline,id desc"
+ _inherit = ['mail.thread', 'mail.activity.mixin', 'utm.mixin']
_mail_mass_mailing = _('Leads / Opportunities')
def _default_probability(self):
@@ -116,12 +115,6 @@ class Lead(FormatAddress, models.Model):
probability = fields.Float('Probability', group_operator="avg", default=lambda self: self._default_probability())
planned_revenue = fields.Float('Expected Revenue', track_visibility='always')
date_deadline = fields.Date('Expected Closing', help="Estimate of the date on which the opportunity will be won.")
-
- # CRM Actions
- next_activity_id = fields.Many2one("crm.activity", string="Next Activity", index=True)
- date_action = fields.Date('Next Activity Date', index=True)
- title_action = fields.Char('Next Activity Summary')
-
color = fields.Integer('Color Index', default=0)
partner_address_name = fields.Char('Partner Contact Name', related='partner_id.name', readonly=True)
partner_address_email = fields.Char('Partner Contact Email', related='partner_id.email', readonly=True)
@@ -170,8 +163,8 @@ class Lead(FormatAddress, models.Model):
today = date.today()
for lead in self:
kanban_state = 'grey'
- if lead.date_action:
- lead_date = fields.Date.from_string(lead.date_action)
+ if lead.activity_date_deadline:
+ lead_date = fields.Date.from_string(lead.activity_date_deadline)
if lead_date >= today:
kanban_state = 'green'
else:
@@ -270,18 +263,6 @@ class Lead(FormatAddress, models.Model):
if self.state_id:
self.country_id = self.state_id.country_id.id
- @api.onchange('next_activity_id')
- def _onchange_next_activity_id(self):
- values = {
- 'title_action': False,
- 'date_action': False,
- }
- if self.next_activity_id:
- values['title_action'] = self.next_activity_id.description
- if self.next_activity_id.days:
- values['date_action'] = fields.Datetime.to_string(datetime.now() + timedelta(days=self.next_activity_id.days))
- self.update(values)
-
# ----------------------------------------
# ORM override (CRUD, fields_view_get, ...)
# ----------------------------------------
@@ -934,13 +915,13 @@ class Lead(FormatAddress, models.Model):
if date_deadline < date.today():
result['closing']['overdue'] += 1
# Next activities
- if opp.next_activity_id and opp.date_action:
- date_action = fields.Date.from_string(opp.date_action)
- if date_action == date.today():
+ for activity in opp.activity_ids:
+ date_deadline = fields.Date.from_string(activity.date_deadline)
+ if date_deadline == date.today():
result['activity']['today'] += 1
- if date.today() <= date_action <= date.today() + timedelta(days=7):
+ if date.today() <= date_deadline <= date.today() + timedelta(days=7):
result['activity']['next_7_days'] += 1
- if date_action < date.today():
+ if date_deadline < date.today():
result['activity']['overdue'] += 1
# Won in Opportunities
if opp.date_closed:
@@ -957,19 +938,19 @@ class Lead(FormatAddress, models.Model):
# crm.activity is a very messy model so we need to do that in order to retrieve the actions done.
self._cr.execute("""
SELECT
- m.id,
- m.subtype_id,
- m.date,
- l.user_id,
- l.type
- FROM mail_message M
- LEFT JOIN crm_lead L ON (M.res_id = L.id)
- INNER JOIN crm_activity A ON (M.subtype_id = A.subtype_id)
+ mail_message.id,
+ mail_message.subtype_id,
+ mail_message.mail_activity_type_id,
+ mail_message.date,
+ crm_lead.user_id,
+ crm_lead.type
+ FROM mail_message
+ LEFT JOIN crm_lead ON (mail_message.res_id = crm_lead.id)
+ INNER JOIN mail_activity_type activity_type ON (mail_message.mail_activity_type_id = activity_type.id)
WHERE
- (M.model = 'crm.lead') AND (L.user_id = %s) AND (L.type = 'opportunity')
+ (mail_message.model = 'crm.lead') AND (crm_lead.user_id = %s) AND (crm_lead.type = 'opportunity')
""", (self._uid,))
activites_done = self._cr.dictfetchall()
-
for activity in activites_done:
if activity['date']:
date_act = fields.Date.from_string(activity['date'])
diff --git a/addons/crm/report/crm_activity_report.py b/addons/crm/report/crm_activity_report.py
index dd2dbc3925f..976886a3f5a 100644
--- a/addons/crm/report/crm_activity_report.py
+++ b/addons/crm/report/crm_activity_report.py
@@ -18,7 +18,8 @@ class ActivityReport(models.Model):
team_id = fields.Many2one('crm.team', 'Sales Team', readonly=True)
lead_id = fields.Many2one('crm.lead', "Lead", readonly=True)
subject = fields.Char('Summary', readonly=True)
- subtype_id = fields.Many2one('mail.message.subtype', 'Activity', readonly=True)
+ subtype_id = fields.Many2one('mail.message.subtype', 'Subtype', readonly=True)
+ mail_activity_type_id = fields.Many2one('mail.activity.type', 'Activity Type', readonly=True)
country_id = fields.Many2one('res.country', 'Country', readonly=True)
company_id = fields.Many2one('res.company', 'Company', readonly=True)
stage_id = fields.Many2one('crm.stage', 'Stage', readonly=True)
@@ -37,6 +38,7 @@ class ActivityReport(models.Model):
select
m.id,
m.subtype_id,
+ m.mail_activity_type_id,
m.author_id,
m.date,
m.subject,
@@ -57,5 +59,5 @@ class ActivityReport(models.Model):
on
(m.res_id = l.id)
WHERE
- (m.model = 'crm.lead')
+ (m.model = 'crm.lead' AND m.mail_activity_type_id IS NOT NULL)
)""")
diff --git a/addons/crm/report/crm_activity_report_views.xml b/addons/crm/report/crm_activity_report_views.xml
index 78c6c3f68b4..689d9fa01f4 100644
--- a/addons/crm/report/crm_activity_report_views.xml
+++ b/addons/crm/report/crm_activity_report_views.xml
@@ -6,7 +6,7 @@
crm.activity.report
-
+
@@ -17,7 +17,7 @@
crm.activity.report
-
+
@@ -28,7 +28,7 @@
crm.activity.report
-
+
@@ -58,7 +58,7 @@
crm.activity.reportformpivot,graph
- {'search_default_my_activity': True}
+ {'search_default_activities_my': True}[]
diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv
index 919f2c7a17d..b1490fb08e2 100644
--- a/addons/crm/security/ir.model.access.csv
+++ b/addons/crm/security/ir.model.access.csv
@@ -18,9 +18,6 @@ access_crm_lead_tag_manager,crm_lead_tag manager,model_crm_lead_tag,sales_team.g
access_crm_lost_reason_manager,crm.lost.reason.manager,model_crm_lost_reason,sales_team.group_sale_manager,1,1,1,1
access_crm_lost_reason_salesman,crm.lost.reason.salesman,model_crm_lost_reason,sales_team.group_sale_salesman,1,0,0,0
access_crm_lost_reason_user,crm.lost.reason.user,model_crm_lost_reason,base.group_user,1,0,0,0
-access_crm_activity_user,crm.activity.user,model_crm_activity,base.group_user,1,1,1,0
-access_crm_activity_manager,crm.activity.manager,model_crm_activity,sales_team.group_sale_manager,1,1,1,1
-access_crm_activity_salesman,crm.activity.salesman,model_crm_activity,sales_team.group_sale_salesman,1,1,1,0
access_crm_activity_report_user,crm.activity.report.user,model_crm_activity_report,base.group_user,1,0,0,0
access_calendar_event_manager,calendar.event.manager,calendar.model_calendar_event,sales_team.group_sale_manager,1,1,1,1
access_calendar_event,calendar.event,calendar.model_calendar_event,sales_team.group_sale_salesman,1,1,1,0
diff --git a/addons/crm/static/src/js/tour.js b/addons/crm/static/src/js/tour.js
index 4ad9b8093f2..7d27e6205d3 100644
--- a/addons/crm/static/src/js/tour.js
+++ b/addons/crm/static/src/js/tour.js
@@ -35,18 +35,22 @@ tour.register('crm_tour', {
position: "right",
run: "drag_and_drop .o_opportunity_kanban .o_kanban_group:eq(2) ",
}, {
- trigger: ".o_kanban_record:not(.o_updating) .oe_kanban_status_grey",
+ trigger: ".o_kanban_record:not(.o_updating) .o_activity_color_default",
extra_trigger: ".o_opportunity_kanban",
- content: _t("This opportunity has no next activity scheduled. Click to set one."),
+ content: _t("This opportunity has no activity planned. Click to check them."),
position: "bottom"
}, {
- trigger: ".o_recommended_activity .o_radio_item",
+ trigger: ".o_schedule_activity",
+ extra_trigger: ".o_opportunity_kanban",
+ content: _t("Schedule an activity by clicking here"),
+ position: "bottom"
+}, {
+ trigger: ".modal-body .o_form_field_many2one",
extra_trigger: ".o_opportunity_kanban",
content: _t("
You will be able to customize your followup activities. Examples:
introductory email
call 10 days after
second call 3 days after, ...
Select a standard activity for now on.
"),
- position: "left",
+ position: "bottom",
run: function (actions) {
- actions.auto(this.$anchor.children("input").first());
- actions.auto(".modal-footer .btn-primary");
+ actions.auto(".modal-footer .btn-default");
},
}, {
trigger: ".o_kanban_record",
diff --git a/addons/crm/tests/test_crm_activity.py b/addons/crm/tests/test_crm_activity.py
index 01747143ace..b18840e75f7 100644
--- a/addons/crm/tests/test_crm_activity.py
+++ b/addons/crm/tests/test_crm_activity.py
@@ -3,52 +3,47 @@
from .common import TestCrmCases
from odoo import fields
-from datetime import date
+from datetime import datetime, timedelta
-class TestCrmActivity(TestCrmCases):
+class TestCrmMailActivity(TestCrmCases):
def setUp(self):
- super(TestCrmActivity, self).setUp()
+ super(TestCrmMailActivity, self).setUp()
# Set up activities
- Activity = self.env['crm.activity']
- self.activity3 = Activity.create({
+ lead_model_id = self.env['ir.model'].search([('model', '=', 'crm.lead')]).id
+ ActivityType = self.env['mail.activity.type']
+ self.activity3 = ActivityType.create({
'name': 'Celebrate the sale',
'days': 3,
- 'description': 'ACT 3 : Beers for everyone because I am a good salesman !',
- 'internal': True,
- 'res_model': 'crm.lead',
+ 'summary': 'ACT 3 : Beers for everyone because I am a good salesman !',
+ 'res_model_id': lead_model_id,
})
- self.activity2 = Activity.create({
+ self.activity2 = ActivityType.create({
'name': 'Call for Demo',
'days': 6,
- 'description': 'ACT 2 : I want to show you my ERP !',
- 'internal': True,
- 'res_model': 'crm.lead',
- 'recommended_activity_ids': [(6, 0, [self.activity3.id])],
+ 'summary': 'ACT 2 : I want to show you my ERP !',
+ 'res_model_id': lead_model_id,
})
- self.activity1 = Activity.create({
+ self.activity1 = ActivityType.create({
'name': 'Initial Contact',
'days': 5,
- 'description': 'ACT 1 : Presentation, barbecue, ... ',
- 'internal': True,
- 'res_model': 'crm.lead',
- 'recommended_activity_ids': [(6, 0, [self.activity2.id])],
+ 'summary': 'ACT 1 : Presentation, barbecue, ... ',
+ 'res_model_id': lead_model_id,
})
# I create an opportunity, as salesman
self.partner_client = self.env.ref("base.res_partner_1")
- Lead = self.env['crm.lead'].sudo(self.crm_salesman.id)
- self.lead = Lead.create({
+ self.lead = self.env['crm.lead'].sudo(self.crm_salesman.id).create({
+ 'name': 'Test Opp',
'type': 'opportunity',
- 'name': 'Test Opportunity Activity Log',
'partner_id': self.partner_client.id,
'team_id': self.env.ref("sales_team.team_sales_department").id,
'user_id': self.crm_salesman.id,
})
def test_crm_activity_recipients(self):
- """ This test case check :
+ """ This test case checks
- no internal subtype followed by client
- activity subtype are not default ones
- only activity followers are recipients when this kind of activity is logged
@@ -60,73 +55,60 @@ class TestCrmActivity(TestCrmCases):
self.lead.message_subscribe([self.partner_client.id])
# Check the client is not follower of any internal subtype
- is_internal_subtype_for_client = self.lead.message_follower_ids.filtered(lambda fol: fol.partner_id.id == self.partner_client.id).mapped('subtype_ids.internal')
- self.assertFalse(any(is_internal_subtype_for_client), 'Partner client is following an internal subtype')
+ internal_subtypes = self.lead.message_follower_ids.filtered(lambda fol: fol.partner_id == self.partner_client).mapped('subtype_ids').filtered(lambda subtype: subtype.internal)
+ self.assertFalse(internal_subtypes)
# Add sale manager as follower of default subtypes
self.lead.message_subscribe([self.crm_salemanager.partner_id.id])
- # Make the sale manager follower of the activity subtype
- manager_follower = self.env['mail.followers'].sudo().search([('res_model', '=', 'crm.lead'), ('res_id', '=', self.lead.id), ('partner_id', '=', self.crm_salemanager.partner_id.id)])
- manager_follower.write({
- 'subtype_ids': [(4, activity.subtype_id.id)]
- })
- # Instanciate wizard, trigger onchange lead and set the next activity
- ActivityLogWizard = self.env['crm.activity.log'].sudo(self.crm_salesman.id)
- wizard = ActivityLogWizard.create({
+ activity = self.env['mail.activity'].sudo(self.crm_salesman.id).create({
+ 'activity_type_id': self.activity1.id,
'note': 'Content of the activity to log',
- 'lead_id': self.lead.id,
+ 'res_id': self.lead.id,
+ 'res_model_id': self.env.ref('crm.model_crm_lead').id,
})
- wizard.onchange_lead_id()
- wizard.write({
- 'next_activity_id': activity.id,
- })
- wizard.action_log()
+ activity._onchange_activity_type_id()
+ self.assertEqual(self.lead.activity_type_id, self.activity1)
+ self.assertEqual(self.lead.activity_summary, self.activity1.summary)
+ # self.assertEqual(self.lead.activity_date_deadline, self.activity1.summary)
- # Check message recipients
+ # mark as done, check lead and posted message
+ activity.action_done()
+ self.assertFalse(self.lead.activity_type_id.id)
+ self.assertFalse(self.lead.activity_ids)
activity_message = self.lead.message_ids[0]
- self.assertEqual(activity_message.needaction_partner_ids, self.crm_salemanager.partner_id, 'Only the crm manager should be notified by the activity')
- self.assertEqual(self.lead.next_activity_id.id, False, 'When logging activity, the next activity planned is erased')
+ self.assertEqual(activity_message.needaction_partner_ids, self.crm_salemanager.partner_id)
+ self.assertEqual(activity_message.subtype_id, self.env.ref('mail.mt_activities'))
def test_crm_activity_next_action(self):
""" This test case set the next activity on a lead, log another, and schedule a third. """
# Add the next activity (like we set it from a form view)
- self.lead.write({
- 'next_activity_id': self.activity1.id
+ lead_model_id = self.env['ir.model'].search([('model', '=', 'crm.lead')]).id
+ activity = self.env['mail.activity'].sudo(self.crm_salesman.id).create({
+ 'activity_type_id': self.activity1.id,
+ 'summary': 'My Own Summary',
+ 'res_id': self.lead.id,
+ 'res_model_id': lead_model_id,
})
- self.lead._onchange_next_activity_id()
+ activity._onchange_activity_type_id()
# Check the next activity is correct
- self.assertEqual(self.lead.title_action, self.activity1.description, 'Activity title should be the same on the lead and on the chosen activity')
+ self.assertEqual(self.lead.activity_summary, activity.summary)
+ self.assertEqual(self.lead.activity_type_id, activity.activity_type_id)
+ # self.assertEqual(fields.Datetime.from_string(self.lead.activity_date_deadline), datetime.now() + timedelta(days=activity.activity_type_id.days))
- # Instanciate the wizard to schedule the next activity
- wizard = self.env['crm.activity.log'].sudo(self.crm_salesman.id).create({
+ activity.write({
+ 'activity_type_id': self.activity2.id,
+ 'summary': '',
'note': 'Content of the activity to log',
- 'lead_id': self.lead.id,
})
- wizard.onchange_lead_id()
- wizard.write({
- 'next_activity_id': self.activity2.id,
- })
- wizard.action_log()
+ activity._onchange_activity_type_id()
+
+ self.assertEqual(self.lead.activity_summary, activity.activity_type_id.summary)
+ self.assertEqual(self.lead.activity_type_id, activity.activity_type_id)
+ # self.assertEqual(fields.Datetime.from_string(self.lead.activity_date_deadline), datetime.now() + timedelta(days=activity.activity_type_id.days))
+
+ activity.action_done()
# Check the next activity on the lead has been removed
- self.assertFalse(self.lead.next_activity_id.id, 'No next activity should be set on lead, since we jsut log another activity')
-
- # Instanciate the wizard to schedule the next activity
- self.env['crm.activity.log'].sudo(self.crm_salesman.id).create({
- 'next_activity_id': self.activity3.id,
- 'note': 'Content of the activity to log',
- 'lead_id': self.lead.id,
- })
- wizard.onchange_lead_id()
- wizard.write({
- 'next_activity_id': self.activity3.id,
- })
- wizard.onchange_next_activity_id()
- wizard.action_schedule()
-
- # Check the activity is well scheldule on lead
- delta_days = (fields.Date.from_string(self.lead.date_action) - date.today()).days
- self.assertEqual(self.activity3.days, delta_days, 'The action date should be in the number of days set up on the activity 3')
- self.assertEqual(self.lead.title_action, self.activity3.description, 'Activity title should be the same on the lead and on the activity 3')
+ self.assertFalse(self.lead.activity_type_id)
diff --git a/addons/crm/views/crm_activity_views.xml b/addons/crm/views/crm_activity_views.xml
deleted file mode 100644
index 0950ccec890..00000000000
--- a/addons/crm/views/crm_activity_views.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
- crm.activity.search
- crm.activity
-
-
-
-
-
-
-
-
-
- crm.activity.form
- crm.activity
-
-
-
-
-
-
- crm.activity.tree
- crm.activity
-
-
-
-
-
-
-
-
-
-
-
- Activities
- crm.activity
- form
- tree,form
-
-