[FIX] nfu_sale_order_batch: make sure packages are readable by the user

This commit is contained in:
Niels Göttsch 2025-09-16 17:02:55 +02:00 committed by madmooose
parent bf3eed8669
commit dbc3b32ecd
5 changed files with 50 additions and 64 deletions

View file

@ -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
===========

View file

@ -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",

View file

@ -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)

View file

@ -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
- 1.3.4: store all quantities and round open values
- 1.3.5: make sure packages are readable by the user

View file

@ -387,50 +387,30 @@ and adds a packaging default to sale order batch.</p>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#toc-entry-1">Changelog</a></h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">0.0.1:</th><td class="field-body"><p class="first">Initial module.</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body"><p class="first">rename to nfu_sale_order_batch_packaging</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body"><p class="first">Live</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.2.0:</th><td class="field-body"><p class="first">Add regeneration action for batch products</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.2.1:</th><td class="field-body"><p class="first">refactoring</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.3.0:</th><td class="field-body"><p class="first">add packaging states</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.3.1:</th><td class="field-body"><p class="first">add open_max_qty</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.3.2:</th><td class="field-body"><p class="first">fix color indicator</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.3.3:</th><td class="field-body"><p class="first">Enable packagings on installation</p>
</td>
</tr>
<tr class="field"><th class="field-name">1.3.4:</th><td class="field-body"><ul class="first simple">
<ul class="simple">
<li>0.0.1: Initial module.</li>
<li>1.0.0: rename to nfu_sale_order_batch_packaging</li>
<li>1.1.0: Live</li>
<li>1.2.0: Add regeneration action for batch products</li>
<li>1.2.1: refactoring</li>
<li>1.3.0: add packaging states</li>
<li>1.3.1: add open_max_qty</li>
<li>1.3.2: fix color indicator</li>
<li>1.3.3: Enable packagings on installation</li>
<li><dl class="first docutils">
<dt>1.3.4:</dt>
<dd><ul class="first last">
<li>on creation set max_qty to product_uom_qty if not set</li>
<li>remove zero exception for max_qty</li>
<li>store open_packaging_qty on batch product module to make it sortable</li>
<li>always adjust max_qty to be at least uom_qty except you only set max qty</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">1.3.4:</th><td class="field-body"><p class="first last">store all quantities and round open values</p>
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
</li>
<li>1.3.4: store all quantities and round open values</li>
<li>1.3.5: make sure packages are readable by the user</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>