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

[15.0][ADD] sale_crm_team_invoiced_payment_state: New module #3582

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
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
85 changes: 85 additions & 0 deletions sale_crm_team_invoiced_payment_state/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
====================================
Sale Crm Team Invoiced Payment State
====================================

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

.. |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%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/15.0/sale_crm_team_invoiced_payment_state
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_crm_team_invoiced_payment_state
: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/sale-workflow&target_branch=15.0
:alt: Try me on Runboat

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

Extends CRM Teams to filter invoiced amounts by payment status.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Navigate to **CRM** > **Configuration** > **Settings**.
3. In the Settings view, go to **Team Invoiced Domain** block.
4. Select the desired **Payment Status** to calculate the team's **Invoiced Amount**.

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

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

* Tecnativa

Contributors
~~~~~~~~~~~~

- [Tecnativa](https://www.tecnativa.com):
- Sergio Teruel
- Juan Carlos Oñate

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/sale-workflow <https://github.com/OCA/sale-workflow/tree/15.0/sale_crm_team_invoiced_payment_state>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_crm_team_invoiced_payment_state/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import model
16 changes: 16 additions & 0 deletions sale_crm_team_invoiced_payment_state/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2025 Tecnativa - Juan Carlos Oñate
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sale Crm Team Invoiced Payment State",
"version": "15.0.1.0.0",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"category": "Sale",
"license": "AGPL-3",
"website": "https://github.com/OCA/sale-workflow",
"depends": ["sale", "crm"],
"data": [
"views/res_config_settings_views.xml",
],
"installable": True,
}
3 changes: 3 additions & 0 deletions sale_crm_team_invoiced_payment_state/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import crm_team
from . import res_company
from . import res_config_settings
31 changes: 31 additions & 0 deletions sale_crm_team_invoiced_payment_state/model/crm_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import ast

from odoo import fields, models
from odoo.osv import expression


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

def _compute_invoiced(self):
if not self:
return

Check warning on line 12 in sale_crm_team_invoiced_payment_state/model/crm_team.py

View check run for this annotation

Codecov / codecov/patch

sale_crm_team_invoiced_payment_state/model/crm_team.py#L12

Added line #L12 was not covered by tests

crm_team_invoiced_domain = self.env.company.crm_team_invoiced_domain
if not crm_team_invoiced_domain:
return super(CrmTeam, self)._compute_invoiced()

Check warning on line 16 in sale_crm_team_invoiced_payment_state/model/crm_team.py

View check run for this annotation

Codecov / codecov/patch

sale_crm_team_invoiced_payment_state/model/crm_team.py#L16

Added line #L16 was not covered by tests
today = fields.Date.today()
invoiced_domain = [
("move_type", "in", ["out_invoice", "out_refund", "out_receipt"]),
("team_id", "in", self.ids),
("date", ">=", fields.Date.to_string(today.replace(day=1))),
("date", "<=", fields.Date.to_string(today)),
]
domain_list = ast.literal_eval(crm_team_invoiced_domain)
invoiced_domain = expression.AND([invoiced_domain, domain_list])
for team in self:
team.invoiced = 0.0
moves = self.env["account.move"].search(invoiced_domain)
for move in moves:
if move.team_id == team:
team.invoiced += move.amount_untaxed_signed
12 changes: 12 additions & 0 deletions sale_crm_team_invoiced_payment_state/model/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import fields, models


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

crm_team_invoiced_domain = fields.Char(
default="['|', '|', "
"['payment_state', '=', 'in_payment'], "
"['payment_state', '=', 'paid'], "
"['payment_state', '=', 'reversed']]"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


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

crm_team_invoiced_domain = fields.Char(
related="company_id.crm_team_invoiced_domain", readonly=False
)
3 changes: 3 additions & 0 deletions sale_crm_team_invoiced_payment_state/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Sergio Teruel
- Juan Carlos Oñate
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extends CRM Teams to filter invoiced amounts by payment status.
3 changes: 3 additions & 0 deletions sale_crm_team_invoiced_payment_state/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1. Navigate to **CRM** > **Configuration** > **Settings**.
3. In the Settings view, go to **Team Invoiced Domain** block.
4. Select the desired **Payment Status** to calculate the team's **Invoiced Amount**.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading