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

[18.0][MIG] product_form_sale_link: Migration to 18.0 #3486

Open
wants to merge 20 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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 product_form_sale_link/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
======================
Product Form Sale Link
======================

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

.. |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/18.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-18-0/sale-workflow-18-0-product_form_sale_link
: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=18.0
:alt: Try me on Runboat

|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|

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

* ACSONE SA/NV

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

- Denis Roussel <[email protected]>
- Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>

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/18.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": "18.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",
],
}
49 changes: 49 additions & 0 deletions product_form_sale_link/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.model,name:product_form_sale_link.model_product_template
msgid "Product"
msgstr ""

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Quotations"
msgstr ""

#. 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:ir.model.fields,field_description:product_form_sale_link.field_product_product__sale_lines_count
#: model:ir.model.fields,field_description:product_form_sale_link.field_product_template__sale_lines_count
msgid "Sales"
msgstr "Vendes"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Sales Orders"
msgstr ""
52 changes: 52 additions & 0 deletions product_form_sale_link/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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: 2023-07-25 12:10+0000\n"
"Last-Translator: Ivorra78 <[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.17\n"

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_template
msgid "Product"
msgstr "Producto"

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_product
msgid "Product Variant"
msgstr "Variante de Producto"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Quotations"
msgstr "Presupuestos"

#. 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:ir.model.fields,field_description:product_form_sale_link.field_product_product__sale_lines_count
#: model:ir.model.fields,field_description:product_form_sale_link.field_product_template__sale_lines_count
msgid "Sales"
msgstr "Ventas"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Sales Orders"
msgstr "Órdenes de venta"

#~ msgid "Sold"
#~ msgstr "Vendido"
49 changes: 49 additions & 0 deletions product_form_sale_link/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.model,name:product_form_sale_link.model_product_template
msgid "Product"
msgstr ""

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Quotations"
msgstr ""

#. 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:ir.model.fields,field_description:product_form_sale_link.field_product_product__sale_lines_count
#: model:ir.model.fields,field_description:product_form_sale_link.field_product_template__sale_lines_count
msgid "Sales"
msgstr "Ventes"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Sales Orders"
msgstr ""
52 changes: 52 additions & 0 deletions product_form_sale_link/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_form_sale_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-07 18:33+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\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.17\n"

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_template
msgid "Product"
msgstr "Prodotto"

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_product
msgid "Product Variant"
msgstr "Variante prodotto"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Quotations"
msgstr "Preventivi"

#. 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 "Righe ordine di vendita"

#. module: product_form_sale_link
#: model:ir.model.fields,field_description:product_form_sale_link.field_product_product__sale_lines_count
#: model:ir.model.fields,field_description:product_form_sale_link.field_product_template__sale_lines_count
msgid "Sales"
msgstr "Vendite"

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Sales Orders"
msgstr "Ordini di vendita"

#~ msgid "Sold"
#~ msgstr "Venduto"
46 changes: 46 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,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_form_sale_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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.model,name:product_form_sale_link.model_product_template
msgid "Product"
msgstr ""

#. module: product_form_sale_link
#: model:ir.model,name:product_form_sale_link.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Quotations"
msgstr ""

#. 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:ir.model.fields,field_description:product_form_sale_link.field_product_product__sale_lines_count
#: model:ir.model.fields,field_description:product_form_sale_link.field_product_template__sale_lines_count
msgid "Sales"
msgstr ""

#. module: product_form_sale_link
#: model_terms:ir.ui.view,arch_db:product_form_sale_link.view_sales_order_line_filter
msgid "Sales Orders"
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
31 changes: 31 additions & 0 deletions product_form_sale_link/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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")

def _compute_sale_lines_count(self):
if (
not self.env.user.has_group("sales_team.group_sale_salesman")
or not self.ids
):
self.sale_lines_count = 0.0
return
domain = [

Check warning on line 19 in product_form_sale_link/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

product_form_sale_link/models/product_product.py#L17-L19

Added lines #L17 - L19 were not covered by tests
("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(

Check warning on line 24 in product_form_sale_link/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

product_form_sale_link/models/product_product.py#L24

Added line #L24 was not covered by tests
domain, ["product_id"], ["product_id"]
)
mapped_data = {

Check warning on line 27 in product_form_sale_link/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

product_form_sale_link/models/product_product.py#L27

Added line #L27 was not covered by tests
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)

Check warning on line 31 in product_form_sale_link/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

product_form_sale_link/models/product_product.py#L31

Added line #L31 was not covered by tests
Loading
Loading