From dbc3b32ecd2ab40967b36c913c6ec9c2b271ac75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20G=C3=B6ttsch?= Date: Tue, 16 Sep 2025 17:02:55 +0200 Subject: [PATCH] [FIX] nfu_sale_order_batch: make sure packages are readable by the user --- nfu_sale_order_batch_packaging/README.rst | 23 ++++---- .../__manifest__.py | 2 +- .../models/sale_order_line.py | 8 ++- .../readme/HISTORY.rst | 23 ++++---- .../static/description/index.html | 58 ++++++------------- 5 files changed, 50 insertions(+), 64 deletions(-) diff --git a/nfu_sale_order_batch_packaging/README.rst b/nfu_sale_order_batch_packaging/README.rst index 2cd979c..1ab8377 100644 --- a/nfu_sale_order_batch_packaging/README.rst +++ b/nfu_sale_order_batch_packaging/README.rst @@ -33,21 +33,22 @@ and adds a packaging default to sale order batch. Changelog ========= -:0.0.1: Initial module. -:1.0.0: rename to nfu_sale_order_batch_packaging -:1.1.0: Live -:1.2.0: Add regeneration action for batch products -:1.2.1: refactoring -:1.3.0: add packaging states -:1.3.1: add open_max_qty -:1.3.2: fix color indicator -:1.3.3: Enable packagings on installation -:1.3.4: +- 0.0.1: Initial module. +- 1.0.0: rename to nfu_sale_order_batch_packaging +- 1.1.0: Live +- 1.2.0: Add regeneration action for batch products +- 1.2.1: refactoring +- 1.3.0: add packaging states +- 1.3.1: add open_max_qty +- 1.3.2: fix color indicator +- 1.3.3: Enable packagings on installation +- 1.3.4: - on creation set max_qty to product_uom_qty if not set - remove zero exception for max_qty - store open_packaging_qty on batch product module to make it sortable - always adjust max_qty to be at least uom_qty except you only set max qty -:1.3.4: store all quantities and round open values +- 1.3.4: store all quantities and round open values +- 1.3.5: make sure packages are readable by the user Bug Tracker =========== diff --git a/nfu_sale_order_batch_packaging/__manifest__.py b/nfu_sale_order_batch_packaging/__manifest__.py index f805b54..627b420 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.3.5", + "version": "16.0.1.3.6", "depends": ["sale", "sale_order_batch"], "data": [ "data/ir_config_parameter.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 6ffa655..c7d927f 100644 --- a/nfu_sale_order_batch_packaging/models/sale_order_line.py +++ b/nfu_sale_order_batch_packaging/models/sale_order_line.py @@ -40,8 +40,12 @@ class SaleOrderLine(models.Model): vals["product_uom_max_qty"] = product_qty if vals.get("product_id") and not vals.get("product_packaging_id"): product_id = vals.get("product_id") - packaging = self.env["product.packaging"].search( - [("product_id", "=", product_id)], limit=1 + # Make sure we're not sudo + # e.x. when comming from webshop + packaging = ( + self.env["product.packaging"] + .with_user(self.env.user) + .search([("product_id", "=", product_id)], limit=1) ) vals["product_packaging_id"] = packaging.id return super().create(vals_list) diff --git a/nfu_sale_order_batch_packaging/readme/HISTORY.rst b/nfu_sale_order_batch_packaging/readme/HISTORY.rst index 815e4d9..c30d813 100644 --- a/nfu_sale_order_batch_packaging/readme/HISTORY.rst +++ b/nfu_sale_order_batch_packaging/readme/HISTORY.rst @@ -1,15 +1,16 @@ -:0.0.1: Initial module. -:1.0.0: rename to nfu_sale_order_batch_packaging -:1.1.0: Live -:1.2.0: Add regeneration action for batch products -:1.2.1: refactoring -:1.3.0: add packaging states -:1.3.1: add open_max_qty -:1.3.2: fix color indicator -:1.3.3: Enable packagings on installation -:1.3.4: +- 0.0.1: Initial module. +- 1.0.0: rename to nfu_sale_order_batch_packaging +- 1.1.0: Live +- 1.2.0: Add regeneration action for batch products +- 1.2.1: refactoring +- 1.3.0: add packaging states +- 1.3.1: add open_max_qty +- 1.3.2: fix color indicator +- 1.3.3: Enable packagings on installation +- 1.3.4: - on creation set max_qty to product_uom_qty if not set - remove zero exception for max_qty - store open_packaging_qty on batch product module to make it sortable - always adjust max_qty to be at least uom_qty except you only set max qty -:1.3.4: store all quantities and round open values \ No newline at end of file +- 1.3.4: store all quantities and round open values +- 1.3.5: make sure packages are readable by the user \ 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 8f0219c..33e4833 100644 --- a/nfu_sale_order_batch_packaging/static/description/index.html +++ b/nfu_sale_order_batch_packaging/static/description/index.html @@ -387,50 +387,30 @@ and adds a packaging default to sale order batch.

Changelog

- --- - - - - - - - - - - - - - - - - - - - - - - - -
0.0.1:

Initial module.

-
1.0.0:

rename to nfu_sale_order_batch_packaging

-
1.1.0:

Live

-
1.2.0:

Add regeneration action for batch products

-
1.2.1:

refactoring

-
1.3.0:

add packaging states

-
1.3.1:

add open_max_qty

-
1.3.2:

fix color indicator

-
1.3.3:

Enable packagings on installation

-
1.3.4:
    +
      +
    • 0.0.1: Initial module.
    • +
    • 1.0.0: rename to nfu_sale_order_batch_packaging
    • +
    • 1.1.0: Live
    • +
    • 1.2.0: Add regeneration action for batch products
    • +
    • 1.2.1: refactoring
    • +
    • 1.3.0: add packaging states
    • +
    • 1.3.1: add open_max_qty
    • +
    • 1.3.2: fix color indicator
    • +
    • 1.3.3: Enable packagings on installation
    • +
    • +
      1.3.4:
      +
      • on creation set max_qty to product_uom_qty if not set
      • remove zero exception for max_qty
      • store open_packaging_qty on batch product module to make it sortable
      • always adjust max_qty to be at least uom_qty except you only set max qty
      -
1.3.4:

store all quantities and round open values

-
+ + + +
  • 1.3.4: store all quantities and round open values
  • +
  • 1.3.5: make sure packages are readable by the user
  • +

    Bug Tracker