Skip to content

Commit

Permalink
Merge PR #2138 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 28, 2023
2 parents 6d578c7 + b73c475 commit 5f19a84
Show file tree
Hide file tree
Showing 21 changed files with 784 additions and 0 deletions.
83 changes: 83 additions & 0 deletions product_form_sale_link/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
======================
Product Form Sale Link
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/14.0/product_form_sale_link
: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-14-0/sale-workflow-14-0-product_form_sale_link
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/14.0
:alt: Try me on Runbot

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

This module adds a button on product forms with a link to sale order lines
for that product.

**Table of contents**

.. contents::
:local:

Usage
=====

Go to Sales > Products > Products

Choose a product and click on 'Sales' button.

.. image:: https://user-images.githubusercontent.com/19529533/61035935-5ec0ef80-a3c8-11e9-836a-4aca2e7dec70.png

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20product_form_sale_link%0Aversion:%2014.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
~~~~~~~

* ACSONE SA/NV

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

* Denis Roussel <[email protected]>

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/14.0/product_form_sale_link>`_ 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 product_form_sale_link/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions product_form_sale_link/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Product Form Sale Link",
"summary": """
Adds a button on product forms to access Sale Lines""",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"category": "Sales",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": ["sale"],
"data": [
"views/sale_order_line.xml",
"views/product_product.xml",
"views/product_template.xml",
],
}
29 changes: 29 additions & 0 deletions product_form_sale_link/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_form_sale_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-03-10 10:45+0000\n"
"Last-Translator: Daniel Martinez Vila <[email protected]>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: product_form_sale_link
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_product_sale_list
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_template_sale_list
msgid "Sale Order Lines"
msgstr "Línies de comandes de venda"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_product_form_view
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_template_form_view
msgid "Sales"
msgstr "Vendes"
29 changes: 29 additions & 0 deletions product_form_sale_link/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_form_sale_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-03-10 10:45+0000\n"
"Last-Translator: Daniel Martinez Vila <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: product_form_sale_link
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_product_sale_list
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_template_sale_list
msgid "Sale Order Lines"
msgstr "Líneas de pedido de venta"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_product_form_view
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_template_form_view
msgid "Sales"
msgstr "Ventas"
29 changes: 29 additions & 0 deletions product_form_sale_link/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_form_sale_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-11-24 15:53+0000\n"
"Last-Translator: Yann Papouin <[email protected]>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 3.10\n"

#. module: product_form_sale_link
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_product_sale_list
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_template_sale_list
msgid "Sale Order Lines"
msgstr "Lignes de commande de vente"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_product_form_view
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_template_form_view
msgid "Sales"
msgstr "Ventes"
26 changes: 26 additions & 0 deletions product_form_sale_link/i18n/product_form_sale_link.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_form_sale_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: product_form_sale_link
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_product_sale_list
#: model:ir.actions.act_window,name:product_form_sale_link.action_product_template_sale_list
msgid "Sale Order Lines"
msgstr ""

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_product_form_view
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.product_template_form_view
msgid "Sales"
msgstr ""
2 changes: 2 additions & 0 deletions product_form_sale_link/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_template
from . import product_product
30 changes: 30 additions & 0 deletions product_form_sale_link/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

sale_lines_count = fields.Integer(
compute="_compute_sale_lines_count", string="Sold"
)

def _compute_sale_lines_count(self):
if not self.user_has_groups("sales_team.group_sale_salesman") or not self.ids:
self.sale_lines_count = 0.0
return
domain = [
("state", "in", ["sale", "done"]),
("product_id", "in", self.ids),
("company_id", "in", self.env.companies.ids),
]
sale_line_data = self.env["sale.order.line"].read_group(
domain, ["product_id"], ["product_id"]
)
mapped_data = {
m["product_id"][0]: m["product_id_count"] for m in sale_line_data
}
for product in self:
product.sale_lines_count = mapped_data.get(product.id, 0)
22 changes: 22 additions & 0 deletions product_form_sale_link/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import logging

from odoo import api, fields, models

_logger = logging.getLogger(__name__)


class ProductTemplate(models.Model):
_inherit = "product.template"

sale_lines_count = fields.Float(compute="_compute_sale_lines_count", string="Sold")

@api.depends("product_variant_ids.sale_lines_count")
def _compute_sale_lines_count(self):
for product in self:
product.sale_lines_count = sum(
p.sale_lines_count
for p in product.with_context(active_test=False).product_variant_ids
)
1 change: 1 addition & 0 deletions product_form_sale_link/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Denis Roussel <[email protected]>
2 changes: 2 additions & 0 deletions product_form_sale_link/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module adds a button on product forms with a link to sale order lines
for that product.
5 changes: 5 additions & 0 deletions product_form_sale_link/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Go to Sales > Products > Products

Choose a product and click on 'Sales' button.

.. image:: https://user-images.githubusercontent.com/19529533/61035935-5ec0ef80-a3c8-11e9-836a-4aca2e7dec70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5f19a84

Please sign in to comment.