diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py
index 9168c1d9e55..785777dfc8c 100644
--- a/addons/stock/models/stock_quant.py
+++ b/addons/stock/models/stock_quant.py
@@ -77,6 +77,7 @@ class StockQuant(models.Model):
'stock.lot', 'Lot/Serial Number', index=True,
ondelete='restrict', check_company=True,
domain=lambda self: self._domain_lot_id())
+ lot_properties = fields.Properties(related='lot_id.lot_properties', definition='product_id.lot_properties_definition', readonly=True)
sn_duplicated = fields.Boolean(string="Duplicated Serial Number", compute='_compute_sn_duplicated', help="If the same SN is in another Quant")
package_id = fields.Many2one(
'stock.quant.package', 'Package',
@@ -185,6 +186,14 @@ class StockQuant(models.Model):
for quant in self:
quant.last_count_date = date_by_quant.get((quant.location_id.id, quant.package_id.id, quant.product_id.id, quant.lot_id.id, quant.owner_id.id))
+ def _search(self, domain, *args, **kwargs):
+ domain = [
+ line if not isinstance(line, (list, tuple)) or not line[0].startswith('lot_properties.')
+ else ['lot_id', 'any', [line]]
+ for line in domain
+ ]
+ return super()._search(domain, *args, **kwargs)
+
@api.depends('inventory_quantity')
def _compute_inventory_diff_quantity(self):
for quant in self:
diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml
index b7e4f402567..5a2d462e3df 100644
--- a/addons/stock/views/stock_quant_views.xml
+++ b/addons/stock/views/stock_quant_views.xml
@@ -28,6 +28,7 @@
+
@@ -146,6 +147,7 @@
+
@@ -450,6 +452,7 @@ in this location. That leads to a negative stock.
+
diff --git a/odoo/fields.py b/odoo/fields.py
index 703c76daef5..91f9f828f07 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -3308,6 +3308,8 @@ class Properties(Field):
return self.convert_to_read_multi([value], record, use_name_get)[0]
def convert_to_read_multi(self, values, records, use_name_get=True):
+ if not records:
+ return values
assert len(values) == len(records)
# each value is either None or a dict
@@ -3419,7 +3421,7 @@ class Properties(Field):
definition_changed = any(
definition.get('definition_changed')
or definition.get('definition_deleted')
- for definition in value
+ for definition in (value or [])
)
if definition_changed:
value = [