diff --git a/product_customerinfo_elaboration/README.rst b/product_customerinfo_elaboration/README.rst new file mode 100644 index 00000000000..e31dc30061a --- /dev/null +++ b/product_customerinfo_elaboration/README.rst @@ -0,0 +1,109 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================= +Product customer info elaboration +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:26f045d301f922a77816e81237d321f03c0b5534d57ab575778f649caeecd352 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/product_customerinfo_elaboration + :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-19-0/sale-workflow-19-0-product_customerinfo_elaboration + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This modules allows to use customers info structure, available in +*Sales* tab of the product form, also for defining customer information, +allowing to define default elaboration per customer and product. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To see this module working you need to define some elaborations as the +module +`sale_elaboration `__ +explains. + +Usage +===== + +To use this module, you need to: + +1. Go to *Sales > Products > Products* +2. Create or select one of existing +3. Go to window *Sales* and create a new entry for some customer +4. Select one elaboration and one elaboration note + +After this create a new quotation and select the partner with that was +configured. You will see that the elaboration and the elaboration note +is completed. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__ : + + - Carlos Roca + - Ernesto Tejeda + - 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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_customerinfo_elaboration/__init__.py b/product_customerinfo_elaboration/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_customerinfo_elaboration/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_customerinfo_elaboration/__manifest__.py b/product_customerinfo_elaboration/__manifest__.py new file mode 100644 index 00000000000..12ec4707146 --- /dev/null +++ b/product_customerinfo_elaboration/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2022 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Product customer info elaboration", + "summary": "Allows to define default elaborations and elaboration notes on product" + " customerinfos", + "version": "19.0.1.0.0", + "development_status": "Beta", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/sale-workflow", + "category": "Sales Management", + "license": "AGPL-3", + "depends": ["product_customerinfo_sale", "sale_elaboration"], + "data": ["security/ir.model.access.csv", "views/product_views.xml"], + "installable": True, +} diff --git a/product_customerinfo_elaboration/i18n/es.po b/product_customerinfo_elaboration/i18n/es.po new file mode 100644 index 00000000000..f7cb8efbc53 --- /dev/null +++ b/product_customerinfo_elaboration/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_supplierinfo_for_customer_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-21 07:23+0000\n" +"PO-Revision-Date: 2022-06-21 09:24+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.3\n" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_product_customerinfo +msgid "Customer Pricelist" +msgstr "Tarifa de cliente" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_ids +msgid "Elaboration" +msgstr "Elaboración" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_note +msgid "Elaboration Note" +msgstr "Nota de elaboración" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_sale_order_line__elaboration_ids +#: model_terms:ir.ui.view,arch_db:product_customerinfo_elaboration.product_customerinfo_form_view +msgid "Elaborations" +msgstr "Elaboraciones" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea pedido de venta" diff --git a/product_customerinfo_elaboration/i18n/it.po b/product_customerinfo_elaboration/i18n/it.po new file mode 100644 index 00000000000..0508309df4d --- /dev/null +++ b/product_customerinfo_elaboration/i18n/it.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_customerinfo_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-08-28 12:25+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 5.10.4\n" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_product_customerinfo +msgid "Customer Pricelist" +msgstr "Listino prezzi cliente" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_ids +msgid "Elaboration" +msgstr "Elaborazione" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_note +msgid "Elaboration Note" +msgstr "Nota elaborazione" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_sale_order_line__elaboration_ids +#: model_terms:ir.ui.view,arch_db:product_customerinfo_elaboration.product_customerinfo_form_view +msgid "Elaborations" +msgstr "Elaborazioni" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga ordine di vendita" diff --git a/product_customerinfo_elaboration/i18n/nl.po b/product_customerinfo_elaboration/i18n/nl.po new file mode 100644 index 00000000000..a310b06937d --- /dev/null +++ b/product_customerinfo_elaboration/i18n/nl.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_customerinfo_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-04-01 15:45+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\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 5.15.2\n" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_product_customerinfo +msgid "Customer Pricelist" +msgstr "Klantprijslijst" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_ids +msgid "Elaboration" +msgstr "Bewerking" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_note +msgid "Elaboration Note" +msgstr "Bewerkingsnotitie" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_sale_order_line__elaboration_ids +#: model_terms:ir.ui.view,arch_db:product_customerinfo_elaboration.product_customerinfo_form_view +msgid "Elaborations" +msgstr "Bewerkingen" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "Verkooporderregel" diff --git a/product_customerinfo_elaboration/i18n/product_customerinfo_elaboration.pot b/product_customerinfo_elaboration/i18n/product_customerinfo_elaboration.pot new file mode 100644 index 00000000000..8a7815ac727 --- /dev/null +++ b/product_customerinfo_elaboration/i18n/product_customerinfo_elaboration.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_customerinfo_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_product_customerinfo +msgid "Customer Pricelist" +msgstr "" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_ids +msgid "Elaboration" +msgstr "" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_product_customerinfo__elaboration_note +msgid "Elaboration Note" +msgstr "" + +#. module: product_customerinfo_elaboration +#: model:ir.model.fields,field_description:product_customerinfo_elaboration.field_sale_order_line__elaboration_ids +#: model_terms:ir.ui.view,arch_db:product_customerinfo_elaboration.product_customerinfo_form_view +msgid "Elaborations" +msgstr "" + +#. module: product_customerinfo_elaboration +#: model:ir.model,name:product_customerinfo_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_customerinfo_elaboration/i18n/product_supplierinfo_for_customer_elaboration.pot b/product_customerinfo_elaboration/i18n/product_supplierinfo_for_customer_elaboration.pot new file mode 100644 index 00000000000..22be4c7df82 --- /dev/null +++ b/product_customerinfo_elaboration/i18n/product_supplierinfo_for_customer_elaboration.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_supplierinfo_for_customer_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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_supplierinfo_for_customer_elaboration +#: model:ir.model,name:product_supplierinfo_for_customer_elaboration.model_product_customerinfo +msgid "Customer Pricelist" +msgstr "" + +#. module: product_supplierinfo_for_customer_elaboration +#: model:ir.model.fields,field_description:product_supplierinfo_for_customer_elaboration.field_product_customerinfo__elaboration_ids +msgid "Elaboration" +msgstr "" + +#. module: product_supplierinfo_for_customer_elaboration +#: model:ir.model.fields,field_description:product_supplierinfo_for_customer_elaboration.field_product_customerinfo__elaboration_note +msgid "Elaboration Note" +msgstr "" + +#. module: product_supplierinfo_for_customer_elaboration +#: model:ir.model.fields,field_description:product_supplierinfo_for_customer_elaboration.field_sale_order_line__elaboration_ids +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_for_customer_elaboration.product_customerinfo_form_view +msgid "Elaborations" +msgstr "" + +#. module: product_supplierinfo_for_customer_elaboration +#: model:ir.model,name:product_supplierinfo_for_customer_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/product_customerinfo_elaboration/models/__init__.py b/product_customerinfo_elaboration/models/__init__.py new file mode 100644 index 00000000000..e844bedddea --- /dev/null +++ b/product_customerinfo_elaboration/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_customerinfo +from . import sale_order_line diff --git a/product_customerinfo_elaboration/models/product_customerinfo.py b/product_customerinfo_elaboration/models/product_customerinfo.py new file mode 100644 index 00000000000..a8a7ea6f37f --- /dev/null +++ b/product_customerinfo_elaboration/models/product_customerinfo.py @@ -0,0 +1,19 @@ +# Copyright 2022 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class ProductCustomerInfo(models.Model): + _inherit = "product.customerinfo" + + elaboration_ids = fields.Many2many(comodel_name="product.elaboration") + elaboration_note = fields.Char( + store=True, + compute="_compute_elaboration_note", + readonly=False, + ) + + @api.depends("elaboration_ids") + def _compute_elaboration_note(self): + for line in self: + line.elaboration_note = ", ".join(line.elaboration_ids.mapped("name")) diff --git a/product_customerinfo_elaboration/models/sale_order_line.py b/product_customerinfo_elaboration/models/sale_order_line.py new file mode 100644 index 00000000000..1f6b7fb7fbc --- /dev/null +++ b/product_customerinfo_elaboration/models/sale_order_line.py @@ -0,0 +1,50 @@ +# Copyright 2022 Tecnativa - Carlos Roca +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + elaboration_ids = fields.Many2many( + comodel_name="product.elaboration", + compute="_compute_elaboration_ids", + store=True, + readonly=False, + string="Elaborations", + ) + + @api.depends("product_id") + def _compute_elaboration_ids(self): + for line in self: + customer_info = line._get_product_customer_info() + if customer_info: + line.elaboration_ids = customer_info.elaboration_ids + + def _get_product_customer_info(self): + customerinfo = self.product_id.customer_ids.filtered( + lambda pc: pc.elaboration_ids and pc.partner_id == self.order_id.partner_id + )[:1] + if not customerinfo: + customerinfo = self.product_id.customer_ids.filtered( + lambda pc: pc.elaboration_ids + and pc.partner_id == self.order_id.partner_id.commercial_partner_id + )[:1] + return customerinfo + + @api.onchange("elaboration_ids") + def onchange_elaboration_ids(self): + for line in self: + customer_info = line._get_product_customer_info() + if ( + customer_info + and line.elaboration_ids + and ( + # Comparing with ids because comparison with newId doesn't work + line.elaboration_ids.ids == customer_info.elaboration_ids.ids + or not line.elaboration_ids + ) + ): + line.elaboration_note = customer_info.elaboration_note diff --git a/product_customerinfo_elaboration/pyproject.toml b/product_customerinfo_elaboration/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_customerinfo_elaboration/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_customerinfo_elaboration/readme/CONFIGURE.md b/product_customerinfo_elaboration/readme/CONFIGURE.md new file mode 100644 index 00000000000..c7e61ed51c3 --- /dev/null +++ b/product_customerinfo_elaboration/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To see this module working you need to define some elaborations as the +module +[sale_elaboration](https://github.com/OCA/sale-workflow/tree/18.0/sale_elaboration) +explains. diff --git a/product_customerinfo_elaboration/readme/CONTRIBUTORS.md b/product_customerinfo_elaboration/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..de852cb8728 --- /dev/null +++ b/product_customerinfo_elaboration/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- [Tecnativa](https://www.tecnativa.com) : + - Carlos Roca + - Ernesto Tejeda + - Sergio Teruel + - Juan Carlos Oñate diff --git a/product_customerinfo_elaboration/readme/DESCRIPTION.md b/product_customerinfo_elaboration/readme/DESCRIPTION.md new file mode 100644 index 00000000000..9f60ca52493 --- /dev/null +++ b/product_customerinfo_elaboration/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This modules allows to use customers info structure, available in +*Sales* tab of the product form, also for defining customer +information, allowing to define default elaboration per customer and +product. diff --git a/product_customerinfo_elaboration/readme/USAGE.md b/product_customerinfo_elaboration/readme/USAGE.md new file mode 100644 index 00000000000..110dd81e196 --- /dev/null +++ b/product_customerinfo_elaboration/readme/USAGE.md @@ -0,0 +1,10 @@ +To use this module, you need to: + +1. Go to *Sales \> Products \> Products* +2. Create or select one of existing +3. Go to window *Sales* and create a new entry for some customer +4. Select one elaboration and one elaboration note + +After this create a new quotation and select the partner with that was +configured. You will see that the elaboration and the elaboration note +is completed. diff --git a/product_customerinfo_elaboration/security/ir.model.access.csv b/product_customerinfo_elaboration/security/ir.model.access.csv new file mode 100644 index 00000000000..f58ad79f61e --- /dev/null +++ b/product_customerinfo_elaboration/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_customerinfo_stock_manager,product.customerinfo.stock_manager,product_customerinfo.model_product_customerinfo,stock.group_stock_manager,1,1,1,1 diff --git a/product_customerinfo_elaboration/static/description/icon.png b/product_customerinfo_elaboration/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_customerinfo_elaboration/static/description/icon.png differ diff --git a/product_customerinfo_elaboration/static/description/index.html b/product_customerinfo_elaboration/static/description/index.html new file mode 100644 index 00000000000..6613e3dc017 --- /dev/null +++ b/product_customerinfo_elaboration/static/description/index.html @@ -0,0 +1,459 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Product customer info elaboration

+ +

Beta License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This modules allows to use customers info structure, available in +Sales tab of the product form, also for defining customer information, +allowing to define default elaboration per customer and product.

+

Table of contents

+ +
+

Configuration

+

To see this module working you need to define some elaborations as the +module +sale_elaboration +explains.

+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Sales > Products > Products
  2. +
  3. Create or select one of existing
  4. +
  5. Go to window Sales and create a new entry for some customer
  6. +
  7. Select one elaboration and one elaboration note
  8. +
+

After this create a new quotation and select the partner with that was +configured. You will see that the elaboration and the elaboration note +is completed.

+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa :
      +
    • Carlos Roca
    • +
    • Ernesto Tejeda
    • +
    • Sergio Teruel
    • +
    • Juan Carlos Oñate
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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_customerinfo_elaboration/tests/__init__.py b/product_customerinfo_elaboration/tests/__init__.py new file mode 100644 index 00000000000..29afd84668f --- /dev/null +++ b/product_customerinfo_elaboration/tests/__init__.py @@ -0,0 +1 @@ +from . import test_customerinfo_elaboration diff --git a/product_customerinfo_elaboration/tests/test_customerinfo_elaboration.py b/product_customerinfo_elaboration/tests/test_customerinfo_elaboration.py new file mode 100644 index 00000000000..e1bc4783b77 --- /dev/null +++ b/product_customerinfo_elaboration/tests/test_customerinfo_elaboration.py @@ -0,0 +1,70 @@ +# Copyright 2022 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo.tests import Form + +from odoo.addons.base.tests.common import BaseCommon + + +class TestCustomerinfoElaboration(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.customer0 = cls.env["res.partner"].create({"name": "Test partner 0"}) + cls.customer1 = cls.env["res.partner"].create( + {"name": "Test partner 1", "parent_id": cls.customer0.id} + ) + cls.customer2 = cls.env["res.partner"].create({"name": "Test partner 2"}) + cls.product = cls.env["product.product"].create({"name": "Product test"}) + cls.product_elab = cls.env["product.product"].create( + {"name": "Elaboration prod. test", "type": "service"} + ) + cls.elaboration = cls.env["product.elaboration"].create( + {"name": "Test elaboration", "product_id": cls.product_elab.id} + ) + cls.customer_info = cls.env["product.customerinfo"].create( + { + "partner_id": cls.customer0.id, + "product_tmpl_id": cls.product.product_tmpl_id.id, + "elaboration_ids": [(4, cls.elaboration.id)], + "elaboration_note": "Test elaboration note", + } + ) + + def _create_sale(self, partner): + so_form = Form(self.env["sale.order"]) + so_form.partner_id = partner + with so_form.order_line.new() as ol_form: + ol_form.product_id = self.product + return so_form.save() + + def test_sale_without_elaboration(self): + so = self._create_sale(self.customer2) + line = so.order_line + self.assertFalse(line.elaboration_ids) + self.assertFalse(line.elaboration_note) + + def test_sale_direct_customerinfo_with_elaboration(self): + so = self._create_sale(self.customer0) + line = so.order_line + self.assertEqual(line.elaboration_ids, self.elaboration) + self.assertEqual(line.elaboration_note, "Test elaboration note") + + def test_sale_parent_customerinfo_with_elaboration(self): + so = self._create_sale(self.customer1) + line = so.order_line + self.assertEqual(line.elaboration_ids, self.elaboration) + self.assertEqual(line.elaboration_note, "Test elaboration note") + + def test_multiple_elaboration_per_customer(self): + product_elab_2 = self.env["product.product"].create( + {"name": "Elaboration prod. test 2", "type": "service"} + ) + elaboration_2 = self.env["product.elaboration"].create( + {"name": "Test elaboration 2", "product_id": product_elab_2.id} + ) + self.customer_info.elaboration_ids += elaboration_2 + so = self._create_sale(self.customer0) + line = so.order_line + self.assertEqual(line.elaboration_ids, self.elaboration | elaboration_2) + self.assertEqual(line.elaboration_note, "Test elaboration, Test elaboration 2") diff --git a/product_customerinfo_elaboration/views/product_views.xml b/product_customerinfo_elaboration/views/product_views.xml new file mode 100644 index 00000000000..cb8297b4441 --- /dev/null +++ b/product_customerinfo_elaboration/views/product_views.xml @@ -0,0 +1,33 @@ + + + + + product.customerinfo + + + + + + + + + + + + product.customerinfo + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt index e69de29bb2d..3104eb30f55 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +odoo-addon-product_customerinfo_sale @ git+https://github.com/OCA/sale-workflow.git@refs/pull/4111/head#subdirectory=product_customerinfo_sale +odoo-addon-sale_elaboration @ git+https://github.com/OCA/sale-workflow.git@refs/pull/4277/head#subdirectory=sale_elaboration