OCA / stock-logistics-warehouse

Odoo Warehouse Management Addons
https://odoo-community.org/psc-teams/logistics-18
GNU Affero General Public License v3.0
320 stars 718 forks source link

MRP with multiple uoms fails to confirm #2060

Open juliaprieto opened 5 months ago

juliaprieto commented 5 months ago

Module

stock_reserve

Describe the bug

When confirming a manufacturing order with products which have different units of mesurements, an error is raised. ValueError: Expected singleton: uom.uom(1, 8) from stock_reserve/models/stock_reserve.py", line 193, in write rounding = self.product_uom.rounding

To Reproduce

Affected versions: 14.0 (maybe others) confirm manufacturing orders

Steps to reproduce the behavior:

  1. Create a manufacturing order,
  2. Add products with different units of measurements (units, meters, g...)
  3. Add amounts available in source stock for each product
  4. Confirm manufacturing orders

Expected behavior Manufacturing order is confirmed and reservations are created for required products

Additional context

dorcyv commented 1 month ago

Is this still relevant? I can't reproduce this bug on version 14.0.

juliaprieto commented 1 month ago

Thank you for your reply. We extended your module (without overriding the write method) to include stock reservations in our stock move workflow. In our customization, we call write method on many stock.reservation at once, which triggers the error. For best practices, the fix should be included in your stock.reservation write method where you set the "rounding" variable line 193 rounding = self.product_uom.rounding that is dependant on the record. To my understanding, the write method should be callable on multiple records at once, what do you think ?