From 06a2d3baaffe7286277b6e2a9335194189a36755 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Thu, 30 Jun 2022 09:20:41 +0000 Subject: [PATCH] [IMP] stock{_account}: update UX of valuation report Note this is specific to the view shown when clicking on "Reporting > Valuation", but this uses the same 'stock.quantity.history' wizard and related custom js as "Configuration > Locations > Current Stock" Minor UX updates to valuation report: - don't default groupby product - add filters incoming and outgoing (same logic as stock.move filters) - replace "Inventory at Date" with "Valuation at Date" where appropriate (but leave location current stock view untouched) - create separate view for the valuation report so remaining qty/value are displayed, but all other svl viewing actions (including the "Valuation at Date") will remain showing the original qty/value to support deeper analysis - don't sum unit_cost when groupby is applied in list view since the value won't make sense - add "reference" to svl which is = to stock.move.reference "valuation" part of b2b task: 2882539 Part-of: odoo/odoo#97109 --- .../js/inventory_report_list_controller.js | 2 +- .../stock/static/src/xml/inventory_report.xml | 4 +- addons/stock_account/__manifest__.py | 6 +++ addons/stock_account/models/stock_quant.py | 1 + .../models/stock_valuation_layer.py | 9 +++- .../static/src/xml/inventory_report.xml | 12 +++++ .../stock_account/views/stock_quant_views.xml | 8 +++- .../views/stock_valuation_layer_views.xml | 46 +++++++++++++++++-- .../wizard/stock_quantity_history.xml | 21 +++++++++ 9 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 addons/stock_account/static/src/xml/inventory_report.xml create mode 100644 addons/stock_account/wizard/stock_quantity_history.xml diff --git a/addons/stock/static/src/js/inventory_report_list_controller.js b/addons/stock/static/src/js/inventory_report_list_controller.js index e2a086002b8..6bbf661b2d4 100644 --- a/addons/stock/static/src/js/inventory_report_list_controller.js +++ b/addons/stock/static/src/js/inventory_report_list_controller.js @@ -31,7 +31,7 @@ var InventoryReportListController = ListController.extend({ // ------------------------------------------------------------------------- /** - * Handler called when the user clicked on the 'Inventory at Date' button. + * Handler called when the user clicked on the 'Valuation at Date' button. * Opens wizard to display, at choice, the products inventory or a computed * inventory at a given date. */ diff --git a/addons/stock/static/src/xml/inventory_report.xml b/addons/stock/static/src/xml/inventory_report.xml index 26a3d0c4adb..5b4484eeb1f 100644 --- a/addons/stock/static/src/xml/inventory_report.xml +++ b/addons/stock/static/src/xml/inventory_report.xml @@ -4,7 +4,9 @@ diff --git a/addons/stock_account/__manifest__.py b/addons/stock_account/__manifest__.py index 78c8a4a0e15..7f5849ce600 100644 --- a/addons/stock_account/__manifest__.py +++ b/addons/stock_account/__manifest__.py @@ -35,10 +35,16 @@ Dashboard / Reports for Warehouse Management includes: 'views/stock_quant_views.xml', 'wizard/stock_request_count.xml', 'wizard/stock_valuation_layer_revaluation_views.xml', + 'wizard/stock_quantity_history.xml', 'report/report_stock_forecasted.xml', ], 'installable': True, 'auto_install': True, 'post_init_hook': '_configure_journals', + 'assets': { + 'web.assets_qweb': [ + 'stock_account/static/src/xml/inventory_report.xml', + ], + }, 'license': 'LGPL-3', } diff --git a/addons/stock_account/models/stock_quant.py b/addons/stock_account/models/stock_quant.py index f569f7b0649..3736a69cf63 100644 --- a/addons/stock_account/models/stock_quant.py +++ b/addons/stock_account/models/stock_quant.py @@ -16,6 +16,7 @@ class StockQuant(models.Model): help="Date at which the accounting entries will be created" " in case of automated inventory valuation." " If empty, the inventory date will be used.") + cost_method = fields.Selection(related="product_categ_id.property_cost_method") @api.depends('company_id', 'location_id', 'owner_id', 'product_id', 'quantity') def _compute_value(self): diff --git a/addons/stock_account/models/stock_valuation_layer.py b/addons/stock_account/models/stock_valuation_layer.py index c2979edac78..3a1f11b25fe 100644 --- a/addons/stock_account/models/stock_valuation_layer.py +++ b/addons/stock_account/models/stock_valuation_layer.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models, tools +from odoo import api, fields, models, tools class StockValuationLayer(models.Model): @@ -29,6 +29,7 @@ class StockValuationLayer(models.Model): stock_valuation_layer_ids = fields.One2many('stock.valuation.layer', 'stock_valuation_layer_id') stock_move_id = fields.Many2one('stock.move', 'Stock Move', readonly=True, check_company=True, index=True) account_move_id = fields.Many2one('account.move', 'Journal Entry', readonly=True, check_company=True) + reference = fields.Char(related='stock_move_id.reference') def init(self): tools.create_index( @@ -55,3 +56,9 @@ class StockValuationLayer(models.Model): def _validate_analytic_accounting_entries(self): for svl in self: svl.stock_move_id._account_analytic_entry_move() + + @api.model + def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True): + if 'unit_cost' in fields: + fields.remove('unit_cost') + return super().read_group(domain, fields, groupby, offset, limit, orderby, lazy) diff --git a/addons/stock_account/static/src/xml/inventory_report.xml b/addons/stock_account/static/src/xml/inventory_report.xml new file mode 100644 index 00000000000..f1679721249 --- /dev/null +++ b/addons/stock_account/static/src/xml/inventory_report.xml @@ -0,0 +1,12 @@ + + + + + + + Valuation at Date + + + + + diff --git a/addons/stock_account/views/stock_quant_views.xml b/addons/stock_account/views/stock_quant_views.xml index 42da52b884e..795cdb4a741 100644 --- a/addons/stock_account/views/stock_quant_views.xml +++ b/addons/stock_account/views/stock_quant_views.xml @@ -19,8 +19,14 @@ + -