From d815505705fdeb67e6d37bad209f684b31433dac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20G=C3=B6ttsch?=
Date: Tue, 30 Jul 2024 16:01:48 +0200
Subject: [PATCH] [imp] in Webshop show max qty as ordered qty and show missing
items per package
---
nfu_ecommerce/README.rst | 1 +
nfu_ecommerce/__manifest__.py | 2 +-
nfu_ecommerce/models/sale_order_line.py | 3 ++-
nfu_ecommerce/readme/HISTORY.rst | 3 ++-
nfu_ecommerce/static/description/index.html | 2 ++
nfu_ecommerce/views/templates.xml | 2 +-
nfu_sale_order_batch_packaging/README.rst | 1 +
nfu_sale_order_batch_packaging/__manifest__.py | 2 +-
.../models/sale_order_line.py | 12 +++++++-----
nfu_sale_order_batch_packaging/readme/HISTORY.rst | 3 ++-
.../static/description/index.html | 2 ++
11 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/nfu_ecommerce/README.rst b/nfu_ecommerce/README.rst
index 6eca94c..68cbf26 100644
--- a/nfu_ecommerce/README.rst
+++ b/nfu_ecommerce/README.rst
@@ -36,6 +36,7 @@ Changelog
=========
:0.0.1: Initial module.
+:1.0.0: Live
Bug Tracker
===========
diff --git a/nfu_ecommerce/__manifest__.py b/nfu_ecommerce/__manifest__.py
index 74cfd89..b5aec0a 100644
--- a/nfu_ecommerce/__manifest__.py
+++ b/nfu_ecommerce/__manifest__.py
@@ -4,7 +4,7 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "website",
- "version": "16.0.0.0.1",
+ "version": "16.0.1.0.0",
"depends": ["website_sale", "nfu_sale_order_batch_packaging"],
"data": ["views/templates.xml"],
"assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]},
diff --git a/nfu_ecommerce/models/sale_order_line.py b/nfu_ecommerce/models/sale_order_line.py
index 00b6a85..4f952a8 100644
--- a/nfu_ecommerce/models/sale_order_line.py
+++ b/nfu_ecommerce/models/sale_order_line.py
@@ -6,5 +6,6 @@ class SaleOrderLine(models.Model):
def compute_open_packages(self):
self.ensure_one()
- open_qty = self.batch_uom_qty % self.product_packaging_id.qty
+ qty_of_last_pack = self.batch_uom_qty % self.product_packaging_id.qty
+ open_qty = self.product_packaging_id.qty - qty_of_last_pack
return open_qty
diff --git a/nfu_ecommerce/readme/HISTORY.rst b/nfu_ecommerce/readme/HISTORY.rst
index e986fe7..e9a3e7c 100644
--- a/nfu_ecommerce/readme/HISTORY.rst
+++ b/nfu_ecommerce/readme/HISTORY.rst
@@ -1 +1,2 @@
-:0.0.1: Initial module.
\ No newline at end of file
+:0.0.1: Initial module.
+:1.0.0: Live
\ No newline at end of file
diff --git a/nfu_ecommerce/static/description/index.html b/nfu_ecommerce/static/description/index.html
index 1beceae..6d36996 100644
--- a/nfu_ecommerce/static/description/index.html
+++ b/nfu_ecommerce/static/description/index.html
@@ -395,6 +395,8 @@ and after the current order.
| 0.0.1: | Initial module. |
+| 1.0.0: | Live |
+
diff --git a/nfu_ecommerce/views/templates.xml b/nfu_ecommerce/views/templates.xml
index 00d6a52..6c4a828 100644
--- a/nfu_ecommerce/views/templates.xml
+++ b/nfu_ecommerce/views/templates.xml
@@ -6,7 +6,7 @@
Open Package: /
- Total Ordered Quantity:
+ Ordered Quantity:
diff --git a/nfu_sale_order_batch_packaging/README.rst b/nfu_sale_order_batch_packaging/README.rst
index 08329e7..167f57f 100644
--- a/nfu_sale_order_batch_packaging/README.rst
+++ b/nfu_sale_order_batch_packaging/README.rst
@@ -35,6 +35,7 @@ Changelog
:0.0.1: Initial module.
:1.0.0: rename to nfu_sale_order_batch_packaging
+:1.1.0: Live
Bug Tracker
===========
diff --git a/nfu_sale_order_batch_packaging/__manifest__.py b/nfu_sale_order_batch_packaging/__manifest__.py
index a2258d4..0ecdd3d 100644
--- a/nfu_sale_order_batch_packaging/__manifest__.py
+++ b/nfu_sale_order_batch_packaging/__manifest__.py
@@ -4,7 +4,7 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "Sale",
- "version": "16.0.1.0.0",
+ "version": "16.0.1.1.0",
"depends": ["sale", "sale_order_batch"],
"data": [
"views/sale_order_views.xml",
diff --git a/nfu_sale_order_batch_packaging/models/sale_order_line.py b/nfu_sale_order_batch_packaging/models/sale_order_line.py
index 1305009..e01a175 100644
--- a/nfu_sale_order_batch_packaging/models/sale_order_line.py
+++ b/nfu_sale_order_batch_packaging/models/sale_order_line.py
@@ -9,6 +9,7 @@ class SaleOrderLine(models.Model):
product_uom_ordered_qty = fields.Float(string="Ordered Qty", digits="Product Unit of Measure", default=1.0)
product_uom_max_qty = fields.Float(string="Max Qty", digits="Product Unit of Measure")
batch_uom_qty = fields.Float(compute="_compute_batch_uom_qty")
+ batch_uom_max_qty = fields.Float(compute="_compute_batch_uom_qty")
@api.constrains("product_uom_qty", "product_uom_max_qty")
def _check_product_uom_qty(self):
@@ -21,20 +22,21 @@ class SaleOrderLine(models.Model):
)
)
- @api.depends("product_uom_qty")
+ @api.depends("product_uom_qty", "product_uom_max_qty")
def _compute_batch_uom_qty(self):
for line in self:
if line.order_id.batch_id:
batch_id = line.batch_id
product_id = line.product_id
- batch_uom_qtys = (
+ batch_lines = (
self.env["sale.order.line"]
.sudo()
.search([("batch_id", "=", batch_id.id), ("product_id", "=", product_id.id)])
- ).mapped("product_uom_qty")
- line.batch_uom_qty = sum(batch_uom_qtys)
+ )
+ line.batch_uom_qty = sum(batch_lines.mapped("product_uom_qty"))
+ line.batch_uom_max_qty = sum(batch_lines.mapped("product_uom_max_qty"))
else:
- line.batch_uom_qty = 0
+ line.batch_uom_max_qty = line.batch_uom_qty = 0
@api.depends("product_packaging_id", "product_uom", "product_uom_qty", "batch_id")
def _compute_product_packaging_qty(self):
diff --git a/nfu_sale_order_batch_packaging/readme/HISTORY.rst b/nfu_sale_order_batch_packaging/readme/HISTORY.rst
index ce67226..918d67d 100644
--- a/nfu_sale_order_batch_packaging/readme/HISTORY.rst
+++ b/nfu_sale_order_batch_packaging/readme/HISTORY.rst
@@ -1,2 +1,3 @@
:0.0.1: Initial module.
-:1.0.0: rename to nfu_sale_order_batch_packaging
\ No newline at end of file
+:1.0.0: rename to nfu_sale_order_batch_packaging
+:1.1.0: Live
\ No newline at end of file
diff --git a/nfu_sale_order_batch_packaging/static/description/index.html b/nfu_sale_order_batch_packaging/static/description/index.html
index 211bb0f..ff7ebcd 100644
--- a/nfu_sale_order_batch_packaging/static/description/index.html
+++ b/nfu_sale_order_batch_packaging/static/description/index.html
@@ -395,6 +395,8 @@ and adds a packaging default to sale order batch.
| 1.0.0: | rename to nfu_sale_order_batch_packaging |
+| 1.1.0: | Live |
+