From f6f141559fc2e0c923e56f6a280f502d2b6f19c8 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 30 Jul 2019 11:52:40 +0000 Subject: [PATCH] [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 --- addons/stock/models/stock_inventory.py | 13 ++++++++++++- addons/stock/views/stock_inventory_views.xml | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index c38e8c08aed..f9a08e4747d 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -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): diff --git a/addons/stock/views/stock_inventory_views.xml b/addons/stock/views/stock_inventory_views.xml index d6b0ce73885..e202e1f4dab 100644 --- a/addons/stock/views/stock_inventory_views.xml +++ b/addons/stock/views/stock_inventory_views.xml @@ -83,6 +83,8 @@ +