[IMP] stock: show lot properties on quants
Since stock.quant are directly related to their lot/serial, we want to be able to show the lot properties on the related quants. We also want to be able to filter quants based on the properties of their lot/serial. closes odoo/odoo#125197 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<field name="package_id" groups="stock.group_tracking_lot"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||
<field name="owner_id" groups="stock.group_tracking_owner"/>
|
||||
<field name="lot_properties"/>
|
||||
<group expand='0' string='Filters'>
|
||||
<filter name='internal_loc' string="Internal Locations" domain="[('location_id.usage','=', 'internal')]"/>
|
||||
<filter name='transit_loc' string="Transit Locations" domain="[('location_id.usage' ,'=', 'transit')]"/>
|
||||
@@ -146,6 +147,7 @@
|
||||
<button name="%(action_view_inventory_tree)d" title="Inventory Adjustment" type="action" class="btn-link" icon="fa-pencil" context="{'search_default_product_id': product_id, 'default_product_id': product_id}"/>
|
||||
<field name="reserved_quantity" optional="show" sum="Total Reserved"/>
|
||||
<field name="product_uom_id" string="Unit" groups="uom.group_uom"/>
|
||||
<field name="lot_properties" optional="hide"/>
|
||||
<button name="action_view_stock_moves" string="History" type="object" class="btn-link" icon="fa-history"/>
|
||||
<button name="action_view_orderpoints" string="Replenishment" type="object" context="{'default_product_id': product_id, 'search_default_location_id': location_id}" class="btn-link" icon="fa-refresh"/>
|
||||
</tree>
|
||||
@@ -450,6 +452,7 @@ in this location. That leads to a negative stock.
|
||||
<field name="inventory_date" optional="show"/>
|
||||
<field name="user_id" string="User" optional="show"/>
|
||||
<field name='company_id' groups="base.group_multi_company" optional="hide"/>
|
||||
<field name="lot_properties" optional="hide"/>
|
||||
<button name="action_inventory_history" type="object" class="btn btn-link text-info" icon="fa-history" string="History"/>
|
||||
<button name="action_apply_inventory" groups="stock.group_stock_manager" type="object" string="Apply" class="btn btn-link" icon="fa-save" attrs="{'invisible': [('inventory_quantity_set', '=', False)]}"/>
|
||||
<button name="action_set_inventory_quantity" type="object" string="Set" class="btn btn-link" icon="fa-bullseye" attrs="{'invisible': [('inventory_quantity_set', '=', True)]}"/>
|
||||
|
||||
+3
-1
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user