Skip to content

Commit 304368b

Browse files
[ADD] sale_crm_recurring_activities
1 parent fbfaa14 commit 304368b

17 files changed

Lines changed: 879 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
5+
=============================
6+
Sale CRM recurring activities
7+
=============================
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:19ba3dbbaf601ea67ce4090c3d4ca863b9caa301d8219d0b8759e03f46e5f1ec
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Beta
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
22+
:alt: License: AGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github
24+
:target: https://github.com/OCA/crm/tree/16.0/sale_crm_recurring_activities
25+
:alt: OCA/crm
26+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27+
:target: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-sale_crm_recurring_activities
28+
:alt: Translate me on Weblate
29+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/crm&target_branch=16.0
31+
:alt: Try me on Runboat
32+
33+
|badge1| |badge2| |badge3| |badge4| |badge5|
34+
35+
This module adds a table that allows you to program Recurring Activities
36+
linked to Opportunities. It is possible to change the activity type, the
37+
assigned user, the summary, the note and the scheduled Days. These
38+
Activities will be activated when a Quotation linked to the opportunity
39+
is confirmed.
40+
41+
**Table of contents**
42+
43+
.. contents::
44+
:local:
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/crm/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us to smash it by providing a detailed and welcomed
52+
`feedback <https://github.com/OCA/crm/issues/new?body=module:%20sale_crm_recurring_activities%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
54+
Do not contact contributors directly about support or help with technical issues.
55+
56+
Credits
57+
=======
58+
59+
Authors
60+
-------
61+
62+
* PyTech SRL
63+
64+
Contributors
65+
------------
66+
67+
- `PyTech SRL <https://pytech.it>`__:
68+
69+
- Alessandro Pecchini <alessandro.pecchini@pytech.it>
70+
71+
Maintainers
72+
-----------
73+
74+
This module is maintained by the OCA.
75+
76+
.. image:: https://odoo-community.org/logo.png
77+
:alt: Odoo Community Association
78+
:target: https://odoo-community.org
79+
80+
OCA, or the Odoo Community Association, is a nonprofit organization whose
81+
mission is to support the collaborative development of Odoo features and
82+
promote its widespread use.
83+
84+
This module is part of the `OCA/crm <https://github.com/OCA/crm/tree/16.0/sale_crm_recurring_activities>`_ project on GitHub.
85+
86+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Sale CRM recurring activities",
3+
"summary": """
4+
Add recurring activities to opportunity after quotation has been confirmed
5+
""",
6+
"author": "PyTech SRL, Odoo Community Association (OCA)",
7+
"license": "AGPL-3",
8+
"website": "https://github.com/OCA/crm",
9+
"category": "Hidden",
10+
"version": "16.0.1.0.0",
11+
"depends": [
12+
"html_text",
13+
"sale_crm",
14+
],
15+
"data": [
16+
"security/ir.model.access.csv",
17+
"security/ir_rules.xml",
18+
"views/crm_recurring_activity_views.xml",
19+
],
20+
"installable": True,
21+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import crm_recurring_activity
2+
from . import res_company
3+
from . import sale_order
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from odoo import _, api, fields, models
2+
from odoo.exceptions import ValidationError
3+
4+
5+
class CrmRecurringActivity(models.Model):
6+
_name = "crm.recurring.activity"
7+
_description = "CRM Recurring activity"
8+
9+
company_id = fields.Many2one(
10+
comodel_name="res.company",
11+
default=lambda self: self.env.company.id,
12+
required=True,
13+
)
14+
activity_type_id = fields.Many2one(
15+
"mail.activity.type",
16+
ondelete="restrict",
17+
domain="[('res_model', 'in', [False, 'crm.lead'])]",
18+
)
19+
user_id = fields.Many2one(
20+
"res.users",
21+
string="Assigned to",
22+
required=True,
23+
)
24+
summary = fields.Char(
25+
compute="_compute_on_activity_type_id",
26+
store=True,
27+
readonly=False,
28+
)
29+
note = fields.Html(
30+
sanitize_style=True,
31+
compute="_compute_on_activity_type_id",
32+
store=True,
33+
readonly=False,
34+
)
35+
scheduled_days = fields.Integer()
36+
37+
@api.constrains("user_id", "company_id")
38+
def _check_user_id(self):
39+
for rec in self:
40+
user = rec.user_id
41+
company = rec.company_id
42+
if not user or not company:
43+
continue
44+
if not user.active or user.share:
45+
raise ValidationError(
46+
_(
47+
"You can only assign recurring activities "
48+
"to active internal users."
49+
)
50+
)
51+
if company not in user.company_ids:
52+
raise ValidationError(
53+
_(
54+
"Assigned user %(user)s "
55+
"does not have access to company: %(company)s.",
56+
user=user.display_name,
57+
company=company.display_name,
58+
)
59+
)
60+
if not self.env.user.has_group("sales_team.group_sale_salesman"):
61+
raise ValidationError(
62+
_("The user does not have permission to use the CRM app")
63+
)
64+
65+
@api.depends("activity_type_id")
66+
def _compute_on_activity_type_id(self):
67+
for activity in self:
68+
if activity.activity_type_id:
69+
if activity.activity_type_id.summary:
70+
activity.summary = self.activity_type_id.summary
71+
if activity.activity_type_id.default_note:
72+
activity.note = self.activity_type_id.default_note
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from odoo import fields, models
2+
3+
4+
class ResCompany(models.Model):
5+
_inherit = "res.company"
6+
7+
crm_recurring_activity_ids = fields.One2many(
8+
"crm.recurring.activity",
9+
"company_id",
10+
string="Recurring Activities",
11+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from datetime import timedelta
2+
3+
from odoo import fields, models
4+
5+
6+
class SaleOrder(models.Model):
7+
_inherit = "sale.order"
8+
9+
def action_confirm(self):
10+
for order in self:
11+
crm_opportunity = order.opportunity_id
12+
if not crm_opportunity:
13+
continue
14+
activities = order.sudo().company_id.crm_recurring_activity_ids
15+
for item in activities:
16+
crm_opportunity.activity_schedule(
17+
date_deadline=fields.Date.today()
18+
+ timedelta(days=item.scheduled_days),
19+
summary=item.summary,
20+
note=item.note,
21+
activity_type_id=item.activity_type_id.id,
22+
user_id=item.user_id.id,
23+
)
24+
return super().action_confirm()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [PyTech SRL](https://pytech.it):
2+
- Alessandro Pecchini \<<alessandro.pecchini@pytech.it>\>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This module adds a table that allows you to program Recurring Activities linked to
2+
Opportunities. It is possible to change the activity type, the assigned user, the
3+
summary, the note and the scheduled Days. These Activities will be activated when a
4+
Quotation linked to the opportunity is confirmed.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_crm_recurring_activity_admin,access.crm.recurring.activity,model_crm_recurring_activity,sales_team.group_sale_manager,1,1,1,1

0 commit comments

Comments
 (0)