From cac406c03373e32db99643c4ac819c93a5c5e1ec 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 | 9 +++++++--
.../static/description/index.html | 6 +++---
.../test_sale_procurement_group_by_line.py | 2 +-
5 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/sale_procurement_group_by_line/README.rst b/sale_procurement_group_by_line/README.rst
index 86d4482d04d..a25b42ae1dc 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 a9cd3b43d51..8909b15ef38 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 d825dac3c08..b1d0f2eeb0c 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,10 +87,10 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False):
line_uom = line.product_uom
quant_uom = line.product_id.uom_id
+
product_qty, procurement_uom = line_uom._adjust_uom_quantities(
product_qty, quant_uom
)
-
procurements.append(
self.env["procurement.group"].Procurement(
line.product_id,
@@ -99,6 +103,7 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False):
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 ee9ea823bae..f89ca75b762 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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
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 @@
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 @@
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 3f0a0a9e207..f781ea0d934 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