Skip to content

Commit

Permalink
[15.0][ADD] Module added to create task from lead/opportunities
Browse files Browse the repository at this point in the history
@moduon MT-3175

Co-authored-by: Rafael Blasco <[email protected]>
Co-authored-by: Jairo Llopis <[email protected]>
  • Loading branch information
3 people committed Jul 19, 2023
1 parent cfc4f26 commit 5badfc5
Show file tree
Hide file tree
Showing 22 changed files with 518 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crm_project_task/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**This file is going to be generated by oca-gen-addon-readme.**

*Manual changes will be overwritten.*

Please provide content in the ``readme`` directory:

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

A good, one sentence summary in the manifest is also highly recommended.


Automatic changelog generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_.

Just put towncrier compatible changelog fragments into `readme/newsfragments`
and the changelog file will be automatically generated and updated when a new fragment is added.

Please refer to `towncrier` documentation to know more.

NOTE: the changelog will be automatically generated when using `/ocabot merge $option`.
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_.
2 changes: 2 additions & 0 deletions crm_project_task/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
26 changes: 26 additions & 0 deletions crm_project_task/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Moduon Team S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "CRM Project Task",
"summary": "Create tasks from lead or opportunity",
"version": "15.0.1.0.0",
"development_status": "Alpha",
"category": "Sales/CRM",
"website": "https://github.com/OCA/crm",
"author": "Moduon, Odoo Community Association (OCA)",
"maintainers": ["EmilioPascual"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"crm",
"project",
],
"data": [
"security/ir.model.access.csv",
"views/res_config_settings.xml",
"wizards/crm_create_task.xml",
"views/crm_lead.xml",
],
}
166 changes: 166 additions & 0 deletions crm_project_task/i18n/crm_project_task.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_project_task
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-18 15:31+0000\n"
"PO-Revision-Date: 2023-07-18 15:31+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: crm_project_task
#: model_terms:ir.ui.view,arch_db:crm_project_task.res_config_settings_view_form
msgid ""
"By default this project will be selected to create task from lead / "
"opportunity"
msgstr ""

#. module: crm_project_task
#: model_terms:ir.ui.view,arch_db:crm_project_task.wizard_crm_create_task_view_form
msgid "Cancel"
msgstr ""

#. module: crm_project_task
#: model:ir.model,name:crm_project_task.model_res_company
msgid "Companies"
msgstr ""

#. module: crm_project_task
#: model:ir.model,name:crm_project_task.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: crm_project_task
#: model:ir.actions.act_window,name:crm_project_task.wizard_crm_create_task_action
#: model_terms:ir.ui.view,arch_db:crm_project_task.inherit_crm_lead_view_form_crm_project_task
#: model_terms:ir.ui.view,arch_db:crm_project_task.wizard_crm_create_task_view_form
msgid "Create Task"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__create_uid
msgid "Created by"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__create_date
msgid "Created on"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_res_company__crm_default_project_id
#: model:ir.model.fields,field_description:crm_project_task.field_res_config_settings__crm_default_project_id
msgid "Crm Default Project"
msgstr ""

#. module: crm_project_task
#: model_terms:ir.ui.view,arch_db:crm_project_task.res_config_settings_view_form
msgid "Default project"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__description
msgid "Description"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__display_name
msgid "Display Name"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__id
msgid "ID"
msgstr ""

#. module: crm_project_task
#. openerp-web
#: code:addons/crm_project_task/static/src/js/web_module_name.tour.js:0
#, python-format
msgid "Instructions for end user."
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task____last_update
msgid "Last Modified on"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__write_uid
msgid "Last Updated by"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__write_date
msgid "Last Updated on"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__lead_id
msgid "Lead"
msgstr ""

#. module: crm_project_task
#: model:ir.model.fields,field_description:crm_project_task.field_crm_create_task__task_name
msgid "Name Task"
msgstr ""

#. module: crm_project_task
#: code:addons/crm_project_task/wizards/crm_create_task.py:0
#, python-format
msgid ""
"Project not configured in settings, please contact with your administrator."
msgstr ""

#. module: crm_project_task
#: model_terms:ir.ui.view,arch_db:crm_project_task.res_config_settings_view_form
msgid "Projects"
msgstr ""

#. module: crm_project_task
#: code:addons/crm_project_task/wizards/crm_create_task.py:0
#, python-format
msgid ""
"Task <a href=# data-oe-model=project.task data-oe-id=%d>%s</a> created."
msgstr ""

#. module: crm_project_task
#: code:addons/crm_project_task/wizards/crm_create_task.py:0
#, python-format
msgid ""
"Task created from lead/opportunity <a href=# data-oe-model=crm.lead data-oe-"
"id=%d>%s</a>."
msgstr ""

#. module: crm_project_task
#. openerp-web
#: code:addons/crm_project_task/static/src/js/web_module_name.tour.js:0
#, python-format
msgid "Text for continue button."
msgstr ""

#. module: crm_project_task
#. openerp-web
#: code:addons/crm_project_task/static/src/js/web_module_name.tour.js:0
#, python-format
msgid "The title of this step, appears in logs"
msgstr ""

#. module: crm_project_task
#. openerp-web
#: code:addons/crm_project_task/static/src/js/web_module_name.tour.js:0
#, python-format
msgid "Try to demonstrate how to create a tour"
msgstr ""

#. module: crm_project_task
#: model:ir.model,name:crm_project_task.model_crm_create_task
msgid "Wizard to create task"
msgstr ""
2 changes: 2 additions & 0 deletions crm_project_task/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_config_settings
from . import res_company
10 changes: 10 additions & 0 deletions crm_project_task/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 Moduon Team S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

crm_default_project_id = fields.Many2one("project.project")
13 changes: 13 additions & 0 deletions crm_project_task/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Moduon Team S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)


from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

crm_default_project_id = fields.Many2one(
related="company_id.crm_default_project_id", readonly=False
)
6 changes: 6 additions & 0 deletions crm_project_task/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To configure this module, you need to:

* Go to Project
* Create a project with right configuration in order that all salesman have access (usually all employees)
* Go to CRM > Configuration > Project
* Set crm default project
2 changes: 2 additions & 0 deletions crm_project_task/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Emilio Pascual (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)
1 change: 1 addition & 0 deletions crm_project_task/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allow create task from leads/opportunities
7 changes: 7 additions & 0 deletions crm_project_task/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#. Go to *CRM > Sales > My pipeline*.
#. Open one of the existing leads or create one.
#. Click on the button "Create Task".
#. A popup will appear asking you name and description for create task.
#. Click on "Create Task" button.
#. A task will be created with project in settings.
#. A message chatter will be created in task with link for lead/opportunity. Also, a message chatter will be creat in lead/opportunity with link for task.
2 changes: 2 additions & 0 deletions crm_project_task/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_crm_create_task,crm.create.task.user,model_crm_create_task,sales_team.group_sale_salesman,1,1,1,1
Binary file added crm_project_task/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions crm_project_task/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_crm_project_task
80 changes: 80 additions & 0 deletions crm_project_task/tests/test_crm_project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2023 Moduon Team S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.tests.common import TransactionCase

from odoo.addons.mail.tests.common import mail_new_test_user


@tagged("post_install", "-at_install")
class TestCrmProjectTask(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.company = cls.env.user.company_id
cls.user_salesman = mail_new_test_user(
cls.env,
login="user_test",
name="User Test",
email="[email protected]",
company_id=cls.company.id,
groups="sales_team.group_sale_salesman",
)
cls.partner = cls.env["res.partner"].create(
{
"name": "Partner Test",
}
)
cls.lead = cls.env["crm.lead"].create(
{
"name": "Test Lead",
"type": "lead",
"partner_id": cls.partner.id,
"user_id": cls.user_salesman.id,
}
)
cls.project = cls.env["project.project"].create(
{
"name": "Test Project",
"description": "Test Description",
}
)

def test_create_task(self):
self.company.crm_default_project_id = self.project
self.task_name = "Task Test"
self.task_description = "Line1</br>Line2"
prev_tasks = self.project.task_ids
self.env["crm.create.task"].with_user(self.user_salesman).create(
{
"lead_id": self.lead.id,
"task_name": self.task_name,
"description": self.task_description,
}
).create_task()
tasks = self.project.task_ids
self.assertEqual(len(prev_tasks) + 1, len(tasks))
task = tasks - prev_tasks
self.assertEqual(task.name, self.task_name)
self.assertEqual(task.project_id, self.company.crm_default_project_id)
self.assertEqual(task.partner_id, self.partner)

def test_create_task_no_project(self):
self.company.crm_default_project_id = False
self.task_name = "Task Test"
self.task_description = "Line1</br>Line2"
wizard = (
self.env["crm.create.task"]
.with_user(self.user_salesman)
.create(
{
"lead_id": self.lead.id,
"task_name": self.task_name,
"description": self.task_description,
}
)
)
with self.assertRaises(UserError):
wizard.create_task()
23 changes: 23 additions & 0 deletions crm_project_task/views/crm_lead.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Moduon Team S.L.
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<odoo>
<record id="inherit_crm_lead_view_form_crm_project_task" model="ir.ui.view">
<field name="name">crm.lead.view.form.inherit.crm.project.task</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form" />
<field name="arch" type="xml">
<xpath expr="header" position="inside">
<button
string="Create Task"
name="%(wizard_crm_create_task_action)d"
type="action"
class="oe_highlight"
context="{'default_lead_id': active_id, 'default_task_name': name}"
attrs="{'invisible': [('active','=',False)]}"
/>
</xpath>
</field>
</record>

</odoo>
Loading

0 comments on commit 5badfc5

Please sign in to comment.