mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_inventory: improve errors information when inventory is blocked
This commit is contained in:
@@ -273,18 +273,28 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
search_filter.append(("product_id", "in", self.product_ids.ids))
|
||||
error_field = "product_id"
|
||||
error_message = _(
|
||||
"There are active adjustments for the requested products: %s"
|
||||
"There are active adjustments for the requested products: %(names)s. "
|
||||
"Blocking adjustments: %(blocking_names)s"
|
||||
)
|
||||
else:
|
||||
error_field = "location_id"
|
||||
error_message = _(
|
||||
"There's already an Adjustment in Process using one requested Location: %s"
|
||||
"There's already an Adjustment in Process "
|
||||
"using one requested Location: %(names)s. "
|
||||
"Blocking adjustments: %(blocking_names)s"
|
||||
)
|
||||
|
||||
quants = self.env["stock.quant"].search(search_filter)
|
||||
if quants:
|
||||
names = self._get_quant_joined_names(quants, error_field)
|
||||
raise ValidationError(error_message % names)
|
||||
inventory_ids = self.env["stock.inventory"].search(
|
||||
[("stock_quant_ids", "in", quants.ids), ("state", "=", "in_progress")]
|
||||
)
|
||||
if inventory_ids:
|
||||
blocking_names = ", ".join(inventory_ids.mapped("name"))
|
||||
names = self._get_quant_joined_names(quants, error_field)
|
||||
raise ValidationError(
|
||||
error_message % {"names": names, "blocking_names": blocking_names}
|
||||
)
|
||||
|
||||
quants = self._get_quants(self.location_ids)
|
||||
self.write(
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
<field name="location_ids" />
|
||||
<field name="date" />
|
||||
<field name="state" />
|
||||
<field name="product_ids" string="Product" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user