Skip to content
Open
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
113 changes: 113 additions & 0 deletions crm_commission/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
==============
CRM Commission
==============

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

.. |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-OCA%2Fcommission-lightgray.png?logo=github
:target: https://github.com/OCA/commission/tree/18.0/crm_commission
:alt: OCA/commission
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/commission-18-0/commission-18-0-crm_commission
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module bridges the CRM and commission modules by allowing
commission agents to be assigned directly on leads and opportunities.

When a lead is converted into an opportunity and a customer is created
or linked, the agents defined on the lead are automatically propagated
to the partner's ``agent_ids`` field. This ensures that sale orders
generated from that opportunity will inherit the correct commission
agents through the standard ``sale_commission_oca`` computation.

**Table of contents**

.. contents::
:local:

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

No special configuration is needed. Just install the module and the
``Agents`` field will appear on the lead/opportunity form, next to the
tags field.

Make sure your agents are properly configured in the ``commission_oca``
module (partners with the *Creditor/Agent* flag enabled and a commission
assigned).

Usage
=====

1. Open a lead or opportunity in the CRM.

2. In the **Agents** field, select one or more commission agents.

3. When converting the lead to an opportunity:

- **Create a new customer**: the new partner will be created with the
agents already assigned.
- **Link to an existing customer**: the agents will be added to the
existing partner (without duplicating agents already present).

4. Any sale order created for that partner will automatically inherit
the commission agents on its lines (via ``sale_commission_oca``).

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/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/OCA/commission/issues/new?body=module:%20crm_commission%0Aversion:%2018.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
-------

* KMEE

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

- `KMEE <https://www.kmee.com.br>`__:

- Luis Felipe Mileo

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/18.0/crm_commission>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions crm_commission/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
17 changes: 17 additions & 0 deletions crm_commission/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "CRM Commission",
"version": "18.0.1.0.0",
"category": "Sales/CRM",
"summary": "Propagate commission agents from CRM leads to partners",
"author": "KMEE, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/commission",
"license": "AGPL-3",
"depends": [
"crm",
"commission_oca",
],
"data": [
"views/crm_lead_views.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions crm_commission/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import crm_lead
24 changes: 24 additions & 0 deletions crm_commission/models/crm_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import fields, models


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

lead_agent_ids = fields.Many2many(
comodel_name="res.partner",
relation="crm_lead_agent_rel",
column1="lead_id",
column2="agent_id",
string="Agentes",
domain=[("agent", "=", True)],
help="Agentes comissionados para este lead. "
"Serão propagados ao cliente na conversão.",
)

def _prepare_customer_values(self, partner_name, is_company=False, parent_id=False):
vals = super()._prepare_customer_values(
partner_name, is_company=is_company, parent_id=parent_id
)
if self.lead_agent_ids:
vals["agent_ids"] = [(6, 0, self.lead_agent_ids.ids)]
return vals
3 changes: 3 additions & 0 deletions crm_commission/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions crm_commission/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
No special configuration is needed. Just install the module and the
``Agents`` field will appear on the lead/opportunity form, next to the
tags field.

Make sure your agents are properly configured in the ``commission_oca``
module (partners with the *Creditor/Agent* flag enabled and a commission
assigned).
2 changes: 2 additions & 0 deletions crm_commission/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [KMEE](https://www.kmee.com.br):
- Luis Felipe Mileo
8 changes: 8 additions & 0 deletions crm_commission/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module bridges the CRM and commission modules by allowing commission
agents to be assigned directly on leads and opportunities.

When a lead is converted into an opportunity and a customer is created or
linked, the agents defined on the lead are automatically propagated to the
partner's ``agent_ids`` field. This ensures that sale orders generated from
that opportunity will inherit the correct commission agents through the
standard ``sale_commission_oca`` computation.
11 changes: 11 additions & 0 deletions crm_commission/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1. Open a lead or opportunity in the CRM.
2. In the **Agents** field, select one or more commission agents.
3. When converting the lead to an opportunity:

- **Create a new customer**: the new partner will be created with the
agents already assigned.
- **Link to an existing customer**: the agents will be added to the
existing partner (without duplicating agents already present).

4. Any sale order created for that partner will automatically inherit the
commission agents on its lines (via ``sale_commission_oca``).
Loading
Loading