Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T-6494][17.0][ADD]crm_assign_project: allows to automatically assign a project to a CRM lead #13

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions crm_assign_project/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
==================
CRM Assign Project
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f12f92a7b3b43b634b25a7a9cfeb8d47e6e839783428e0a4f466c00ac654b700
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-sygel--technology%2Fsy--crm-lightgray.png?logo=github
:target: https://github.com/sygel-technology/sy-crm/tree/17.0/crm_assign_project
:alt: sygel-technology/sy-crm

|badge1| |badge2| |badge3|

This module allows to automatically assign a project to a CRM lead when
a lead/opportunity is created through an email.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

1. Go to CRM > Configuration > Sales Teams and select a team.
2. Check the 'Assign Project' checkbox
3. Select a value in 'Automatically Assigned Project'

Usage
=====

To usage this module, you need to:

1. Create a new Lead, manually or sending a email to an alias, with a
Crm Team with a project_id
2. The created lead will have the configured project_id

Known issues / Roadmap
======================

- Manually created leads with the fast creation popup wizard won't have
a default project_id, even if the user has a default team_id with a
default project_id. The reason is this is made with an onchange.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/sygel-technology/sy-crm/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/sygel-technology/sy-crm/issues/new?body=module:%20crm_assign_project%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Sygel

Contributors
------------

- Harald Panten harald.panten@sygel.es
- Valentin Vinagre valentin.vinagre@sygel.es
- Alberto Martínez alberto.martinez@sygel.es
- Roger Sans roger.sans@sygel.es

Maintainers
-----------

This module is part of the `sygel-technology/sy-crm <https://github.com/sygel-technology/sy-crm/tree/17.0/crm_assign_project>`_ project on GitHub.

You are welcome to contribute.
4 changes: 4 additions & 0 deletions crm_assign_project/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
18 changes: 18 additions & 0 deletions crm_assign_project/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "CRM Assign Project",
"summary": "Automatically assign project to CRM lead.",
"version": "17.0.1.0.0",
"category": "CRM",
"website": "https://github.com/sygel-technology/sy-crm",
"author": "Sygel, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["crm", "sales_team", "crm_timesheet"],
"data": [
"views/crm_team_views.xml",
],
}
33 changes: 33 additions & 0 deletions crm_assign_project/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_assign_project
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-07-12 11:45+0000\n"
"PO-Revision-Date: 2022-07-12 13:45+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: es\n"
"X-Generator: Poedit 2.3\n"

#. module: crm_assign_project
#: model:ir.model.fields,field_description:crm_assign_project.field_crm_team__automatic_project_assignation
msgid "Assign Project"
msgstr "Asignar proyecto"

#. module: crm_assign_project
#: model:ir.model.fields,field_description:crm_assign_project.field_crm_team__automatic_assignation_project_id
msgid "Automatically Assigned Project"
msgstr "Proyecto asignado automáticamente"

#. module: crm_assign_project
#: model:ir.model,name:crm_assign_project.model_crm_team
msgid "Sales Channels"
msgstr "Canales de Ventas"
5 changes: 5 additions & 0 deletions crm_assign_project/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import crm_team
from . import crm_lead
17 changes: 17 additions & 0 deletions crm_assign_project/models/crm_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class CrmLead(models.Model):
_inherit = "crm.lead"

@api.onchange("team_id")
def _onchange_team_id(self):
if (
self.team_id
and self.team_id.automatic_project_assignation
and self.team_id.automatic_assignation_project_id
):
self.project_id = self.team_id.automatic_assignation_project_id.id
40 changes: 40 additions & 0 deletions crm_assign_project/models/crm_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class CrmTeam(models.Model):
_inherit = "crm.team"

automatic_project_assignation = fields.Boolean(
string="Assign Project", default=False
)
automatic_assignation_project_id = fields.Many2one(
string="Automatically Assigned Project",
comodel_name="project.project",
)

def write(self, vals):
values = super().write(vals)
if (
"automatic_project_assignation" in vals
or "automatic_assignation_project_id" in vals
) and self.alias_id:
alias_values = self._alias_get_creation_values()
self.alias_id.write({"alias_defaults": alias_values["alias_defaults"]})
return values

def _alias_get_creation_values(self):
values = super()._alias_get_creation_values()
if self.automatic_project_assignation and self.automatic_assignation_project_id:
values["alias_defaults"][
"project_id"
] = self.automatic_assignation_project_id.id
elif (
not self.automatic_project_assignation
and values.get("alias_defaults")
and values.get("alias_defaults").get("project_id")
):
values.get("alias_defaults").pop("project_id")
return values
3 changes: 3 additions & 0 deletions crm_assign_project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions crm_assign_project/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To configure this module, you need to:

1. Go to CRM > Configuration > Sales Teams and select a team.
2. Check the 'Assign Project' checkbox
3. Select a value in 'Automatically Assigned Project'
4 changes: 4 additions & 0 deletions crm_assign_project/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Harald Panten <harald.panten@sygel.es>
- Valentin Vinagre <valentin.vinagre@sygel.es>
- Alberto Martínez <alberto.martinez@sygel.es>
- Roger Sans <roger.sans@sygel.es>
1 change: 1 addition & 0 deletions crm_assign_project/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to automatically assign a project to a CRM lead when a lead/opportunity is created through an email.
1 change: 1 addition & 0 deletions crm_assign_project/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Manually created leads with the fast creation popup wizard won't have a default project_id, even if the user has a default team_id with a default project_id. The reason is this is made with an onchange.
4 changes: 4 additions & 0 deletions crm_assign_project/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To usage this module, you need to:

1. Create a new Lead, manually or sending a email to an alias, with a Crm Team with a project_id
2. The created lead will have the configured project_id
Binary file added crm_assign_project/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.
Loading
Loading