[IMP] nfu_sale_order_batch: always adjust max_qty to be at least uom_qty

This commit is contained in:
Niels Göttsch 2025-05-09 23:21:09 +02:00 committed by madmooose
parent a1487b4fcf
commit 8c8091b4fd
4 changed files with 15 additions and 1 deletions

View file

@ -46,6 +46,7 @@ Changelog
- on creation set max_qty to product_uom_qty if not set - on creation set max_qty to product_uom_qty if not set
- remove zero exception for max_qty - remove zero exception for max_qty
- store open_packaging_qty on batch product module to make it sortable - 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
Bug Tracker Bug Tracker
=========== ===========

View file

@ -32,3 +32,14 @@ class SaleOrderLine(models.Model):
packaging = self.env["product.packaging"].search([("product_id", "=", product_id)], limit=1) packaging = self.env["product.packaging"].search([("product_id", "=", product_id)], limit=1)
vals["product_packaging_id"] = packaging.id vals["product_packaging_id"] = packaging.id
return super().create(vals_list) return super().create(vals_list)
def write(self, vals):
product_qty = vals.get("product_uom_qty")
product_max_qty = vals.get("product_uom_max_qty")
if product_qty and product_max_qty and product_qty > product_max_qty:
vals["product_uom_max_qty"] = product_qty
elif product_qty:
for line in self:
if product_qty > line.product_uom_max_qty:
line["product_uom_max_qty"] = product_qty
return super().write(vals)

View file

@ -11,3 +11,4 @@
- on creation set max_qty to product_uom_qty if not set - on creation set max_qty to product_uom_qty if not set
- remove zero exception for max_qty - remove zero exception for max_qty
- store open_packaging_qty on batch product module to make it sortable - 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

View file

@ -422,6 +422,7 @@ and adds a packaging default to sale order batch.</p>
<li>on creation set max_qty to product_uom_qty if not set</li> <li>on creation set max_qty to product_uom_qty if not set</li>
<li>remove zero exception for max_qty</li> <li>remove zero exception for max_qty</li>
<li>store open_packaging_qty on batch product module to make it sortable</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> </ul>
</td> </td>
</tr> </tr>