diff --git a/sale_product_multi_add/README.rst b/sale_product_multi_add/README.rst index 1f19c92ac5f..0a6f8a5baea 100644 --- a/sale_product_multi_add/README.rst +++ b/sale_product_multi_add/README.rst @@ -17,13 +17,13 @@ Sale Product Multi Add :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/17.0/sale_product_multi_add + :target: https://github.com/OCA/sale-workflow/tree/18.0/sale_product_multi_add :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-17-0/sale-workflow-17-0-sale_product_multi_add + :target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_product_multi_add :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=17.0 + :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| @@ -54,7 +54,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -69,15 +69,16 @@ Authors Contributors ------------ -- Denis Roussel -- Cédric Pigeon -- Tharathip Chaweewongphan -- `Pesol `__: +- Denis Roussel +- Cédric Pigeon +- Tharathip Chaweewongphan +- `Pesol `__: - - Jonathan Oscategui Taza + - Jonathan Oscategui Taza -- Jacques-Etienne Baudoux (BCIM) -- Anaïs López +- Jacques-Etienne Baudoux (BCIM) +- Anaïs López +- Heliconia Solutions Pvt. Ltd. Maintainers ----------- @@ -92,6 +93,6 @@ 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. +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/sale_product_multi_add/__manifest__.py b/sale_product_multi_add/__manifest__.py index 4cab37bbd0d..90f1e8d5e1e 100644 --- a/sale_product_multi_add/__manifest__.py +++ b/sale_product_multi_add/__manifest__.py @@ -7,9 +7,9 @@ "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/sale-workflow", "category": "Sale Management", - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "license": "AGPL-3", - "depends": ["sale"], + "depends": ["sale_stock"], "data": [ "security/ir.model.access.csv", "wizards/sale_import_products_view.xml", diff --git a/sale_product_multi_add/readme/CONTRIBUTORS.md b/sale_product_multi_add/readme/CONTRIBUTORS.md index 0f1e7f8a6fb..ccd9d8238de 100644 --- a/sale_product_multi_add/readme/CONTRIBUTORS.md +++ b/sale_product_multi_add/readme/CONTRIBUTORS.md @@ -5,3 +5,4 @@ - Jonathan Oscategui Taza \<\> - Jacques-Etienne Baudoux (BCIM) \<\> - Anaïs López \<\> +- Heliconia Solutions Pvt. Ltd. \<\> diff --git a/sale_product_multi_add/static/description/index.html b/sale_product_multi_add/static/description/index.html index fa6c1e3a204..e348a63f9fe 100644 --- a/sale_product_multi_add/static/description/index.html +++ b/sale_product_multi_add/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -368,7 +369,7 @@

Sale Product Multi Add

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:76dc6788d1252512000fd3edaef23c4ecde388730ad5d522de42de14499555a1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module extends the functionality of the Sales module by allowing you to import multiple products into your current Sale Order.

Table of contents

@@ -397,7 +398,7 @@

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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -420,16 +421,19 @@

Contributors

  • Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
  • Anaïs López <anais.lopez@forgeflow.com>
  • +
  • Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +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.

    +

    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/sale_product_multi_add/tests/test_sale.py b/sale_product_multi_add/tests/test_sale.py index df1fc1004d7..b904536a11f 100644 --- a/sale_product_multi_add/tests/test_sale.py +++ b/sale_product_multi_add/tests/test_sale.py @@ -1,5 +1,5 @@ -# © 2016-2024 Cédric Pigeon, Acsone SA/NV (http://www.acsone.eu) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from unittest.mock import patch + import odoo.tests.common as common @@ -9,32 +9,80 @@ def setUp(self): self.product_9 = self.env.ref("product.product_product_9") self.product_11 = self.env.ref("product.product_product_11") + self.so = self.env["sale.order"].create( + { + "partner_id": self.env.ref("base.res_partner_2").id, + "picking_policy": "one", + } + ) def test_import_product(self): """Create SO Import products - Check products are presents + Check products are present """ - - so = self.env["sale.order"].create( - {"partner_id": self.env.ref("base.res_partner_2").id} - ) - wiz_obj = self.env["sale.import.products"] - wizard = wiz_obj.with_context(active_id=so.id, active_model="sale.order") + wizard = wiz_obj.with_context(active_id=self.so.id, active_model="sale.order") products = [(6, 0, [self.product_9.id, self.product_11.id])] - wizard_id = wizard.create({"products": products}) + wizard_id = wizard.create([{"products": products}]) wizard_id.create_items() wizard_id.items[0].quantity = 4 wizard_id.items[1].quantity = 6 wizard_id.select_products() - self.assertEqual(len(so.order_line), 2) + self.assertEqual(len(self.so.order_line), 2) - for line in so.order_line: + for line in self.so.order_line: if line.product_id.id == self.product_9.id: self.assertEqual(line.product_uom_qty, 4) else: self.assertEqual(line.product_uom_qty, 6) + + def test_select_products_no_vals(self): + """Test when _get_line_values returns False""" + wizard = self.env["sale.import.products"].create([]) + + # Use unittest.mock to patch the method instead of direct assignment + with patch.object(type(wizard), "_get_line_values", return_value=False): + wizard.with_context(active_id=self.so.id).select_products() + + # Assert that no order lines are created + self.assertEqual(len(self.so.order_line), 0) + + def test_select_products_empty_vals_list(self): + """Test when vals_list is empty""" + wizard = self.env["sale.import.products"].create([]) + wizard.with_context(active_id=self.so.id).select_products() + + # Assert that no order lines are created + self.assertEqual(len(self.so.order_line), 0) + + def test_select_products_no_sale(self): + """Test when sale is not found""" + wizard = self.env["sale.import.products"].create([]) + result = wizard.with_context(active_id=False).select_products() + + # Assert no order lines are created and window action is returned + self.assertEqual(len(self.so.order_line), 0) + self.assertEqual(result, {"type": "ir.actions.act_window_close"}) + + def test_select_products_with_vals(self): + """Test when vals_list is created""" + wiz_obj = self.env["sale.import.products"] + wizard = wiz_obj.with_context(active_id=self.so.id) + products = [(6, 0, [self.product_9.id, self.product_11.id])] + wizard_id = wizard.create([{"products": products}]) + wizard_id.create_items() + wizard_id.items[0].quantity = 3 + wizard_id.items[1].quantity = 5 + wizard_id.select_products() + + # Assert that order lines are created correctly + self.assertEqual(len(self.so.order_line), 2) + for line in self.so.order_line: + if line.product_id.id == self.product_9.id: + self.assertEqual(line.product_uom_qty, 3) + elif line.product_id.id == self.product_11.id: + self.assertEqual(line.product_uom_qty, 5) diff --git a/sale_product_multi_add/views/sale_view.xml b/sale_product_multi_add/views/sale_view.xml index dac35515645..47d569019c7 100644 --- a/sale_product_multi_add/views/sale_view.xml +++ b/sale_product_multi_add/views/sale_view.xml @@ -18,10 +18,7 @@ /> - {'always_reload':true} + {'always_reload':true} diff --git a/sale_product_multi_add/wizards/sale_import_products.py b/sale_product_multi_add/wizards/sale_import_products.py index eda36079702..821ddd157aa 100644 --- a/sale_product_multi_add/wizards/sale_import_products.py +++ b/sale_product_multi_add/wizards/sale_import_products.py @@ -19,7 +19,7 @@ def create_items(self): for wizard in self: for product in wizard.products: self.env["sale.import.products.items"].create( - {"wizard_id": wizard.id, "product_id": product.id} + [{"wizard_id": wizard.id, "product_id": product.id}] ) view = self.env.ref("sale_product_multi_add.view_import_product_to_sale2") return { diff --git a/sale_product_multi_add/wizards/sale_import_products_view.xml b/sale_product_multi_add/wizards/sale_import_products_view.xml index de87ffe6f31..6b3da627ae3 100644 --- a/sale_product_multi_add/wizards/sale_import_products_view.xml +++ b/sale_product_multi_add/wizards/sale_import_products_view.xml @@ -25,10 +25,10 @@
    - + - +