diff --git a/product_form_sale_link/README.rst b/product_form_sale_link/README.rst new file mode 100644 index 00000000000..6c209335c38 --- /dev/null +++ b/product_form_sale_link/README.rst @@ -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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel +- Heliconia Solutions Pvt. Ltd. + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_form_sale_link/__init__.py b/product_form_sale_link/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_form_sale_link/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_form_sale_link/__manifest__.py b/product_form_sale_link/__manifest__.py new file mode 100644 index 00000000000..bedc491d7c9 --- /dev/null +++ b/product_form_sale_link/__manifest__.py @@ -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", + ], +} diff --git a/product_form_sale_link/i18n/ca.po b/product_form_sale_link/i18n/ca.po new file mode 100644 index 00000000000..271964b17bc --- /dev/null +++ b/product_form_sale_link/i18n/ca.po @@ -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 \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 "" diff --git a/product_form_sale_link/i18n/es.po b/product_form_sale_link/i18n/es.po new file mode 100644 index 00000000000..2441b2465ee --- /dev/null +++ b/product_form_sale_link/i18n/es.po @@ -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 \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" diff --git a/product_form_sale_link/i18n/fr.po b/product_form_sale_link/i18n/fr.po new file mode 100644 index 00000000000..29b38b7f715 --- /dev/null +++ b/product_form_sale_link/i18n/fr.po @@ -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 \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 "" diff --git a/product_form_sale_link/i18n/it.po b/product_form_sale_link/i18n/it.po new file mode 100644 index 00000000000..2092738577e --- /dev/null +++ b/product_form_sale_link/i18n/it.po @@ -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 \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" diff --git a/product_form_sale_link/i18n/product_form_sale_link.pot b/product_form_sale_link/i18n/product_form_sale_link.pot new file mode 100644 index 00000000000..43264f6be8d --- /dev/null +++ b/product_form_sale_link/i18n/product_form_sale_link.pot @@ -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 "" diff --git a/product_form_sale_link/models/__init__.py b/product_form_sale_link/models/__init__.py new file mode 100644 index 00000000000..049669dd0fe --- /dev/null +++ b/product_form_sale_link/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_template +from . import product_product diff --git a/product_form_sale_link/models/product_product.py b/product_form_sale_link/models/product_product.py new file mode 100644 index 00000000000..f7f73335d11 --- /dev/null +++ b/product_form_sale_link/models/product_product.py @@ -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 = [ + ("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) diff --git a/product_form_sale_link/models/product_template.py b/product_form_sale_link/models/product_template.py new file mode 100644 index 00000000000..4c7907530b5 --- /dev/null +++ b/product_form_sale_link/models/product_template.py @@ -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") + + @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 + ) diff --git a/product_form_sale_link/pyproject.toml b/product_form_sale_link/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_form_sale_link/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_form_sale_link/readme/CONTRIBUTORS.md b/product_form_sale_link/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..84a4a119075 --- /dev/null +++ b/product_form_sale_link/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Denis Roussel \<\> +- Heliconia Solutions Pvt. Ltd. \<\> diff --git a/product_form_sale_link/readme/DESCRIPTION.md b/product_form_sale_link/readme/DESCRIPTION.md new file mode 100644 index 00000000000..89df2f2e907 --- /dev/null +++ b/product_form_sale_link/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds a button on product forms with a link to sale order +lines for that product. diff --git a/product_form_sale_link/readme/USAGE.md b/product_form_sale_link/readme/USAGE.md new file mode 100644 index 00000000000..731c7769481 --- /dev/null +++ b/product_form_sale_link/readme/USAGE.md @@ -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) diff --git a/product_form_sale_link/static/description/icon.png b/product_form_sale_link/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_form_sale_link/static/description/icon.png differ diff --git a/product_form_sale_link/static/description/index.html b/product_form_sale_link/static/description/index.html new file mode 100644 index 00000000000..d27bb1d3521 --- /dev/null +++ b/product_form_sale_link/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +Product Form Sale Link + + + + + + diff --git a/product_form_sale_link/static/description/product_sale.png b/product_form_sale_link/static/description/product_sale.png new file mode 100644 index 00000000000..f6a92050599 Binary files /dev/null and b/product_form_sale_link/static/description/product_sale.png differ diff --git a/product_form_sale_link/views/product_product.xml b/product_form_sale_link/views/product_product.xml new file mode 100644 index 00000000000..76a39f43687 --- /dev/null +++ b/product_form_sale_link/views/product_product.xml @@ -0,0 +1,24 @@ + + + + + product.product.form (in product_form_sale_link) + product.product + + + + + + + diff --git a/product_form_sale_link/views/product_template.xml b/product_form_sale_link/views/product_template.xml new file mode 100644 index 00000000000..a35a9a45148 --- /dev/null +++ b/product_form_sale_link/views/product_template.xml @@ -0,0 +1,27 @@ + + + + + product.template.form (in product_form_sale_link) + product.template + + +
+ +
+
+
+
diff --git a/product_form_sale_link/views/sale_order_line.xml b/product_form_sale_link/views/sale_order_line.xml new file mode 100644 index 00000000000..1523a06af13 --- /dev/null +++ b/product_form_sale_link/views/sale_order_line.xml @@ -0,0 +1,37 @@ + + + + + sale.order.line + sale.order.line.select (in product_form_sale_link) + + + + + + + + + + + Sale Order Lines + sale.order.line + {'search_default_sales':1} + [('product_id.product_tmpl_id', 'in', active_ids)] + + + Sale Order Lines + sale.order.line + {'search_default_sales':1} + [('product_id', 'in', active_ids)] + +