[IMP] stock: add new filter for inv.adj. lines
New search filter to display of inventory lines with `difference_qty` (diff. between `theoretical_qty` and `product_qty`) different than zero. Task #2043851
This commit is contained in:
@@ -306,7 +306,7 @@ class InventoryLine(models.Model):
|
||||
digits='Product Unit of Measure', readonly=True)
|
||||
difference_qty = fields.Float('Difference', compute='_compute_difference',
|
||||
help="Indicates the gap between the product's theoretical quantity and its newest quantity.",
|
||||
readonly=True, digits='Product Unit of Measure')
|
||||
readonly=True, digits='Product Unit of Measure', search="_search_difference_qty")
|
||||
inventory_date = fields.Datetime('Inventory Date', readonly=True,
|
||||
default=fields.Datetime.now,
|
||||
help="Last date at which the On Hand Quantity has been computed.")
|
||||
@@ -504,6 +504,17 @@ class InventoryLine(models.Model):
|
||||
impacted_lines |= line
|
||||
impacted_lines.write({'product_qty': 0})
|
||||
|
||||
def _search_difference_qty(self, operator, value):
|
||||
if operator == '=':
|
||||
result = True
|
||||
elif operator == '!=':
|
||||
result = False
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
lines = self.search([('inventory_id', '=', self.env.context.get('default_inventory_id'))])
|
||||
line_ids = lines.filtered(lambda line: float_is_zero(line.difference_qty, line.product_id.uom_id.rounding) == result).ids
|
||||
return [('id', 'in', line_ids)]
|
||||
|
||||
def _search_outdated(self, operator, value):
|
||||
if operator != '=':
|
||||
if operator == '!=' and isinstance(value, bool):
|
||||
|
||||
@@ -83,6 +83,8 @@
|
||||
<field name="partner_id" groups="stock.group_tracking_owner"/>
|
||||
<filter string="Outdated Theoretical Quantities"
|
||||
name="outdated" domain="[('outdated', '=', True)]"/>
|
||||
<filter string="Difference different than zero"
|
||||
name="difference" domain="[('difference_qty', '!=', '0')]"/>
|
||||
<group expand='0' string='Group by...'>
|
||||
<filter string='Location' name="location" domain="[]" context="{'group_by' : 'location_id'}"/>
|
||||
<filter string='Packaging' name="packaging" domain="[]" context="{'group_by' : 'package_id'}"/>
|
||||
|
||||
Reference in New Issue
Block a user