From 5dd19a8277affdaa06a4d721cf5ac4626b39da4c Mon Sep 17 00:00:00 2001 From: lreficent Date: Tue, 10 Oct 2017 11:56:46 +0200 Subject: [PATCH] [9.0][IMP] stock_cycle_count: enhance views --- stock_cycle_count/models/stock_inventory.py | 2 +- stock_cycle_count/models/stock_location.py | 11 +++++ .../reports/report_stock_location_accuracy.py | 6 +-- .../views/stock_inventory_view.xml | 49 +++++++++++++++++++ .../views/stock_location_view.xml | 15 ++---- 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/stock_cycle_count/models/stock_inventory.py b/stock_cycle_count/models/stock_inventory.py index c4d755518..f4aad364a 100644 --- a/stock_cycle_count/models/stock_inventory.py +++ b/stock_cycle_count/models/stock_inventory.py @@ -32,7 +32,7 @@ class StockInventory(models.Model): ondelete='cascade', readonly=True) inventory_accuracy = fields.Float( string='Accuracy', compute=_compute_inventory_accuracy, - digits=(3, 2), store=True) + digits=(3, 2), store=True, group_operator="avg") @api.multi def action_done(self): diff --git a/stock_cycle_count/models/stock_location.py b/stock_cycle_count/models/stock_location.py index a9b5730c0..bf040984a 100644 --- a/stock_cycle_count/models/stock_location.py +++ b/stock_cycle_count/models/stock_location.py @@ -91,3 +91,14 @@ class StockLocation(models.Model): 'state': 'draft' }) return True + + @api.multi + def action_accuracy_stats(self): + self.ensure_one() + action = self.env.ref('stock_cycle_count.act_accuracy_stats') + result = action.read()[0] + result['context'] = {"search_default_location_id": self.id} + new_domain = result['domain'][:-1] + \ + ", ('location_id', 'child_of', active_ids)]" + result['domain'] = new_domain + return result diff --git a/stock_cycle_count/reports/report_stock_location_accuracy.py b/stock_cycle_count/reports/report_stock_location_accuracy.py index f2807da1b..6b14a2a2a 100644 --- a/stock_cycle_count/reports/report_stock_location_accuracy.py +++ b/stock_cycle_count/reports/report_stock_location_accuracy.py @@ -3,16 +3,16 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models +from openerp import api, models class LocationAccuracyReport(models.AbstractModel): _name = "report.stock_location_accuracy" @api.model - def _get_inventory_domain(self, loc_id): + def _get_inventory_domain(self, loc_id, exclude_sublocation=True): return [('location_id', '=', loc_id), - ('exclude_sublocation', '=', True), + ('exclude_sublocation', '=', exclude_sublocation), ('state', '=', 'done')] @api.model diff --git a/stock_cycle_count/views/stock_inventory_view.xml b/stock_cycle_count/views/stock_inventory_view.xml index 6bdf9c266..dbc84f4c6 100644 --- a/stock_cycle_count/views/stock_inventory_view.xml +++ b/stock_cycle_count/views/stock_inventory_view.xml @@ -10,6 +10,7 @@ + @@ -31,4 +32,52 @@ + + stock.inventory.filter - stock_cycle_count + stock.inventory + + + + + + + + + + stock.inventory.graph + stock.inventory + + + + + + + + + + stock.inventory.pivot + stock.inventory + + + + + + + + + + + [('exclude_sublocation', '=', True), + ('state', '=', 'done')] + Accuracy Stats + stock.inventory + form + pivot,tree,form,graph + + + + diff --git a/stock_cycle_count/views/stock_location_view.xml b/stock_cycle_count/views/stock_location_view.xml index eef47bbfd..71ef6cced 100644 --- a/stock_cycle_count/views/stock_location_view.xml +++ b/stock_cycle_count/views/stock_location_view.xml @@ -4,16 +4,6 @@ - - [('location_id', '=', active_ids), - ('exclude_sublocation', '=', True), - ('state', '=', 'done')] - Accuracy Stats - stock.inventory - form - tree,form,pivot - - Location form - cycle count extension stock.location @@ -21,8 +11,9 @@