mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
stock_measuring_device: Retrieve product when device is already assigned
This commit is contained in:
committed by
Hai Lang
parent
1e1236776e
commit
a0ffc17f18
@@ -40,7 +40,7 @@ class MeasuringDevice(models.Model):
|
||||
return work_ctx.component(usage=self.device_type)
|
||||
|
||||
def open_wizard(self):
|
||||
return {
|
||||
res = {
|
||||
"name": _("Measurement Wizard"),
|
||||
"res_model": "measuring.wizard",
|
||||
"type": "ir.actions.act_window",
|
||||
@@ -54,6 +54,12 @@ class MeasuringDevice(models.Model):
|
||||
"no_breadcrumbs": True,
|
||||
},
|
||||
}
|
||||
if self._is_being_used():
|
||||
pack = self.env["product.packaging"].search(
|
||||
[("measuring_device_id", "=", self.id)], limit=1
|
||||
)
|
||||
res["context"]["default_product_id"] = pack.product_id.id
|
||||
return res
|
||||
|
||||
def _is_being_used(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -16,6 +16,7 @@ class ProductPackaging(models.Model):
|
||||
string="Measuring device which will scan the package",
|
||||
help="Technical field set when an operator uses the device "
|
||||
"to scan this package",
|
||||
index=True,
|
||||
)
|
||||
|
||||
def _measuring_device_assign(self, device):
|
||||
|
||||
Reference in New Issue
Block a user