stock_measuring_device: Retrieve product when device is already assigned

This commit is contained in:
Matthieu Méquignon
2021-04-28 14:34:27 +02:00
committed by Hai Lang
parent 1e1236776e
commit a0ffc17f18
4 changed files with 24 additions and 1 deletions

View File

@@ -89,6 +89,7 @@ class MeasuringWizard(models.TransientModel):
"barcode": pack.barcode,
"packaging_id": pack.id,
"packaging_type_id": pack_type.id,
"scan_requested": bool(pack.measuring_device_id),
}
)
vals_list.append(vals)
@@ -160,6 +161,15 @@ class MeasuringWizard(models.TransientModel):
"flags": {"headless": False, "clear_breadcrumbs": True},
}
def retrieve_product(self):
"""Assigns product that locks the device if a scan is already requested."""
if self.device_id._is_being_used():
pack = self.env["product.packaging"]._measuring_device_find_assigned(
self.device_id
)
self.product_id = pack.product_id
self.onchange_product_id()
def reload(self):
return {
"type": "ir.actions.act_view_reload",

View File

@@ -37,6 +37,12 @@
string="Refresh"
icon="fa-refresh"
/>
<button
name="retrieve_product"
type="object"
string="Retrieve Product"
icon="fa-search"
/>
</group>
<group name="col2" />
</group>