From 39c49bf630b3abe5f942339ceb9a3cc6d74941fd Mon Sep 17 00:00:00 2001
From: sergio-teruel
Date: Mon, 7 Nov 2022 19:27:34 +0100
Subject: [PATCH] [MIG] stock_picking_report_undelivered_product: Migration to
v15.0
---
.../stock_picking_report_undelivered_product | 1 +
.../setup.py | 6 +++++
.../README.rst | 10 ++++-----
.../__manifest__.py | 2 +-
.../models/__init__.py | 1 +
.../models/product_template.py | 4 +---
.../models/res_config_settings.py | 11 ----------
.../models/res_partner.py | 4 +---
.../models/stock_move.py | 2 +-
.../models/stock_move_line.py | 22 +++++++++++++++++++
.../static/description/index.html | 6 ++---
...tock_picking_report_undelivered_product.py | 18 ++++++++-------
12 files changed, 52 insertions(+), 35 deletions(-)
create mode 120000 setup/stock_picking_report_undelivered_product/odoo/addons/stock_picking_report_undelivered_product
create mode 100644 setup/stock_picking_report_undelivered_product/setup.py
create mode 100644 stock_picking_report_undelivered_product/models/stock_move_line.py
diff --git a/setup/stock_picking_report_undelivered_product/odoo/addons/stock_picking_report_undelivered_product b/setup/stock_picking_report_undelivered_product/odoo/addons/stock_picking_report_undelivered_product
new file mode 120000
index 0000000..86e497d
--- /dev/null
+++ b/setup/stock_picking_report_undelivered_product/odoo/addons/stock_picking_report_undelivered_product
@@ -0,0 +1 @@
+../../../../stock_picking_report_undelivered_product
\ No newline at end of file
diff --git a/setup/stock_picking_report_undelivered_product/setup.py b/setup/stock_picking_report_undelivered_product/setup.py
new file mode 100644
index 0000000..28c57bb
--- /dev/null
+++ b/setup/stock_picking_report_undelivered_product/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)
diff --git a/stock_picking_report_undelivered_product/README.rst b/stock_picking_report_undelivered_product/README.rst
index b11cc1b..4142767 100644
--- a/stock_picking_report_undelivered_product/README.rst
+++ b/stock_picking_report_undelivered_product/README.rst
@@ -14,13 +14,13 @@ Stock picking report undelivered products
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github
- :target: https://github.com/OCA/stock-logistics-reporting/tree/13.0/stock_picking_report_undelivered_product
+ :target: https://github.com/OCA/stock-logistics-reporting/tree/15.0/stock_picking_report_undelivered_product
:alt: OCA/stock-logistics-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-13-0/stock-logistics-reporting-13-0-stock_picking_report_undelivered_product
+ :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-15-0/stock-logistics-reporting-15-0-stock_picking_report_undelivered_product
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/151/13.0
+ :target: https://runbot.odoo-community.org/runbot/151/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -65,7 +65,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 smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -98,6 +98,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/stock-logistics-reporting `_ project on GitHub.
+This module is part of the `OCA/stock-logistics-reporting `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_picking_report_undelivered_product/__manifest__.py b/stock_picking_report_undelivered_product/__manifest__.py
index 692ea76..d9cdc8a 100644
--- a/stock_picking_report_undelivered_product/__manifest__.py
+++ b/stock_picking_report_undelivered_product/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Stock picking report undelivered products",
"summary": "Display on picking report delivery slip undelivered products",
- "version": "13.0.1.0.0",
+ "version": "15.0.1.0.0",
"author": "Tecnativa,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
"category": "Warehouse",
diff --git a/stock_picking_report_undelivered_product/models/__init__.py b/stock_picking_report_undelivered_product/models/__init__.py
index 2096132..d021699 100644
--- a/stock_picking_report_undelivered_product/models/__init__.py
+++ b/stock_picking_report_undelivered_product/models/__init__.py
@@ -2,3 +2,4 @@ from . import product_template
from . import res_config_settings
from . import res_partner
from . import stock_move
+from . import stock_move_line
diff --git a/stock_picking_report_undelivered_product/models/product_template.py b/stock_picking_report_undelivered_product/models/product_template.py
index e9090d0..d230475 100644
--- a/stock_picking_report_undelivered_product/models/product_template.py
+++ b/stock_picking_report_undelivered_product/models/product_template.py
@@ -7,6 +7,4 @@ from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
- display_undelivered_in_picking = fields.Boolean(
- string="Display undelivered in picking", default=True
- )
+ display_undelivered_in_picking = fields.Boolean(default=True)
diff --git a/stock_picking_report_undelivered_product/models/res_config_settings.py b/stock_picking_report_undelivered_product/models/res_config_settings.py
index a67c968..1010629 100644
--- a/stock_picking_report_undelivered_product/models/res_config_settings.py
+++ b/stock_picking_report_undelivered_product/models/res_config_settings.py
@@ -8,17 +8,6 @@ class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
undelivered_product_slip_report_method = fields.Selection(
- [
- ("all", "Display all undelivered product lines"),
- (
- "partially_undelivered",
- "Display only partially undelivered product lines",
- ),
- (
- "completely_undelivered",
- "Display only completely undelivered product lines",
- ),
- ],
string="Method to display undelivered product lines in report picking",
related="company_id.undelivered_product_slip_report_method",
readonly=False,
diff --git a/stock_picking_report_undelivered_product/models/res_partner.py b/stock_picking_report_undelivered_product/models/res_partner.py
index 9443efe..4ba6b75 100644
--- a/stock_picking_report_undelivered_product/models/res_partner.py
+++ b/stock_picking_report_undelivered_product/models/res_partner.py
@@ -7,6 +7,4 @@ from odoo import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
- display_undelivered_in_picking = fields.Boolean(
- string="Display undelivered in picking", default=True
- )
+ display_undelivered_in_picking = fields.Boolean(default=True)
diff --git a/stock_picking_report_undelivered_product/models/stock_move.py b/stock_picking_report_undelivered_product/models/stock_move.py
index d6efae3..9eff265 100644
--- a/stock_picking_report_undelivered_product/models/stock_move.py
+++ b/stock_picking_report_undelivered_product/models/stock_move.py
@@ -15,6 +15,6 @@ class StockMove(models.Model):
"""
Store origin stock move which create splitted move.
"""
- vals = super(StockMove, self)._prepare_move_split_vals(qty)
+ vals = super()._prepare_move_split_vals(qty)
vals["splitted_stock_move_orig_id"] = self.id
return vals
diff --git a/stock_picking_report_undelivered_product/models/stock_move_line.py b/stock_picking_report_undelivered_product/models/stock_move_line.py
new file mode 100644
index 0000000..fb69784
--- /dev/null
+++ b/stock_picking_report_undelivered_product/models/stock_move_line.py
@@ -0,0 +1,22 @@
+# Copyright 2022 Tecnativa - Sergio Teruel
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import models
+
+
+class StockMoveLine(models.Model):
+ _inherit = "stock.move.line"
+
+ def _get_aggregated_product_quantities(self, **kwargs):
+ """Odoo displays products non delivered in main table.
+ So I remove key from it to be displayed in the bottom table
+ """
+ aggregated_move_lines = super()._get_aggregated_product_quantities(**kwargs)
+ keys_to_remove = set()
+ for aggregated_move_line in aggregated_move_lines:
+ if not aggregated_move_lines[aggregated_move_line]["qty_done"]:
+ keys_to_remove.add(aggregated_move_line)
+ # To avoid change dict size on iteration
+ for key_to_remmove in keys_to_remove:
+ aggregated_move_lines.pop(key_to_remmove, None)
+ return aggregated_move_lines
diff --git a/stock_picking_report_undelivered_product/static/description/index.html b/stock_picking_report_undelivered_product/static/description/index.html
index ca4ec8d..6008aac 100644
--- a/stock_picking_report_undelivered_product/static/description/index.html
+++ b/stock_picking_report_undelivered_product/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module extends the functionality of stock module to allow to
display undelivered products in the delivery slip report.
You have three options to display lines:
@@ -414,7 +414,7 @@ completely lines).
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 smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -445,7 +445,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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/stock-logistics-reporting project on GitHub.
+
This module is part of the OCA/stock-logistics-reporting project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py b/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py
index 7537e71..e3331b3 100644
--- a/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py
+++ b/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py
@@ -75,7 +75,9 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
def _transfer_picking_no_backorder(self, picking):
# Transfer picking with no create backorder option
backorder_wizard = self.BackOrderWiz.create({"pick_ids": [(4, picking.id)]})
- backorder_wizard.process_cancel_backorder()
+ backorder_wizard.with_context(
+ button_validate_picking_ids=picking.id
+ ).process_cancel_backorder()
def test_displayed_customer(self):
picking = self._create_picking(self.partner_display)
@@ -86,7 +88,7 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertIn("undelivered_product", str(res[0]))
@@ -99,7 +101,7 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertNotIn("undelivered_product", str(res[0]))
@@ -115,7 +117,7 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertNotIn("undelivered_product", str(res[0]))
@@ -162,7 +164,7 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertIn("test02", str(res[0]))
@@ -171,7 +173,7 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertIn("test02", str(res[0]))
@@ -182,7 +184,7 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertNotIn("test02", str(res[0]))
@@ -193,6 +195,6 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
- .render_qweb_html(picking.ids)
+ ._render_qweb_html(picking.ids)
)
self.assertNotIn("partially_undelivered_line", str(res[0]))