From e6c97a9e2244451607c9cc2131e756c65c022eb1 Mon Sep 17 00:00:00 2001 From: Meritxell Abellan Date: Fri, 22 Nov 2024 09:32:29 +0100 Subject: [PATCH] [MIG] sale_procurement_group_by_line: Migration to 18.0 --- sale_procurement_group_by_line/README.rst | 20 +++++++------- .../__manifest__.py | 2 +- sale_procurement_group_by_line/model/sale.py | 26 +++++++++---------- .../static/description/index.html | 6 ++--- .../test_sale_procurement_group_by_line.py | 6 ++--- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/sale_procurement_group_by_line/README.rst b/sale_procurement_group_by_line/README.rst index 86d4482d04d4..a25b42ae1dcd 100644 --- a/sale_procurement_group_by_line/README.rst +++ b/sale_procurement_group_by_line/README.rst @@ -17,13 +17,13 @@ Sale Procurement Group by Line :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_procurement_group_by_line + :target: https://github.com/OCA/sale-workflow/tree/18.0/sale_procurement_group_by_line :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_procurement_group_by_line + :target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_procurement_group_by_line :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| @@ -45,7 +45,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. @@ -62,11 +62,11 @@ Authors Contributors ------------ -- Guewen Baconnier -- Yannick Vaucher -- Jordi Ballester -- Serpent Consulting Services Pvt. Ltd. -- Carmen Rondon Regalado +- Guewen Baconnier +- Yannick Vaucher +- Jordi Ballester +- Serpent Consulting Services Pvt. Ltd. +- Carmen Rondon Regalado Maintainers ----------- @@ -81,6 +81,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_procurement_group_by_line/__manifest__.py b/sale_procurement_group_by_line/__manifest__.py index a9cd3b43d519..8909b15ef38d 100644 --- a/sale_procurement_group_by_line/__manifest__.py +++ b/sale_procurement_group_by_line/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Sale Procurement Group by Line", "summary": "Base module for multiple procurement group by Sale order", - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "author": "Camptocamp," "ForgeFlow," "Serpent Consulting Services Pvt. Ltd.," diff --git a/sale_procurement_group_by_line/model/sale.py b/sale_procurement_group_by_line/model/sale.py index d825dac3c086..4f049c1fcdb2 100644 --- a/sale_procurement_group_by_line/model/sale.py +++ b/sale_procurement_group_by_line/model/sale.py @@ -40,7 +40,11 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False): previous_product_uom_qty = {} for line in self: line = line.with_company(line.company_id) - if line.state != "sale" or line.product_id.type not in ("consu", "product"): + if ( + line.state != "sale" + or line.order_id.locked + or line.product_id.type != "consu" + ): continue qty = line._get_qty_procurement(previous_product_uom_qty) if ( @@ -83,22 +87,18 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False): line_uom = line.product_uom quant_uom = line.product_id.uom_id + origin = ( + f"{line.order_id.name} - {line.order_id.client_order_ref}" + if line.order_id.client_order_ref + else line.order_id.name + ) product_qty, procurement_uom = line_uom._adjust_uom_quantities( product_qty, quant_uom ) - - procurements.append( - self.env["procurement.group"].Procurement( - line.product_id, - product_qty, - procurement_uom, - line.order_id.partner_shipping_id.property_stock_customer, - line.display_name, - line.order_id.name, - line.order_id.company_id, - values, - ) + procurements += line._create_procurements( + product_qty, procurement_uom, origin, values ) + # We store the procured quantity in the UoM of the line to avoid # duplicated procurements, specially for dropshipping and kits. previous_product_uom_qty[line.id] = line.product_uom_qty diff --git a/sale_procurement_group_by_line/static/description/index.html b/sale_procurement_group_by_line/static/description/index.html index ee9ea823baea..f89ca75b7620 100644 --- a/sale_procurement_group_by_line/static/description/index.html +++ b/sale_procurement_group_by_line/static/description/index.html @@ -368,7 +368,7 @@

Sale Procurement Group by Line

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:30d43a042ae36eb1cfd62b1e80ceb060af0619577b76d9294b6731e946aab47b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module was written to extend the functionality of procurement groups created from a sale order.

On itself, this module does nothing it is a requirement for modules @@ -390,7 +390,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,7 +420,7 @@

Maintainers

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_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py b/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py index 3f0a0a9e2071..1cb5427eeb3c 100644 --- a/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py +++ b/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py @@ -36,7 +36,7 @@ def _create_product_category(cls): @classmethod def _create_product(cls, name): product = cls.product_model.create( - {"name": name, "categ_id": cls.product_ctg.id, "type": "product"} + {"name": name, "categ_id": cls.product_ctg.id, "is_storable": True} ) return product @@ -96,9 +96,9 @@ def test_02_action_launch_procurement_rule_1(self): self.sale.action_confirm() self.assertEqual(self.sale.state, "sale") self.assertEqual(len(self.line1.move_ids), 1) - self.assertEqual(self.line1.move_ids.name, self.line1.display_name) + self.assertEqual(self.line1.move_ids.name, self.line1.product_id.display_name) self.assertEqual(len(self.line2.move_ids), 1) - self.assertEqual(self.line2.move_ids.name, self.line2.display_name) + self.assertEqual(self.line2.move_ids.name, self.line2.product_id.display_name) def test_03_action_launch_procurement_rule_2(self): group_id = self.proc_group_model.create(