From 86c25e1d48045d4c93238d52011fece6d7373ee7 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Wed, 23 Nov 2022 12:12:07 +0100 Subject: [PATCH] add on_demand/on_hand columns to all products_and_inventory/all_products report --- config/locales/en.yml | 3 +++ .../products_and_inventory/all_products.rb | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 9c38d6b867..5ba6475874 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4080,6 +4080,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using select_and_search: "Select filters and click on %{option} to access your data." customer_names_message: customer_names_tip: "If customer names are hidden for orders you have supplied, you can contact the distributor and ask if they can update their shop preferences to allow their suppliers to view customer names." + products_and_inventory: + all_products: + message: "Note that stock levels reported are from supplier product lists only. If you are using Inventory to manage your stock quantities these values will be ignored in this report." users: index: listing_users: "Listing Users" diff --git a/lib/reporting/reports/products_and_inventory/all_products.rb b/lib/reporting/reports/products_and_inventory/all_products.rb index f433f83287..8ec06fded7 100644 --- a/lib/reporting/reports/products_and_inventory/all_products.rb +++ b/lib/reporting/reports/products_and_inventory/all_products.rb @@ -4,6 +4,30 @@ module Reporting module Reports module ProductsAndInventory class AllProducts < Base + def default_params + { fields_to_hide: [:on_demand, :on_hand] } + end + + def message + I18n.t("spree.admin.reports.products_and_inventory.all_products.message") + end + + def custom_headers + { + on_demand: I18n.t("admin.on_demand?"), + on_hand: I18n.t("admin.on_hand") + } + end + + def columns + super.merge( + { + on_demand: proc{ |variant| variant.on_demand }, + on_hand: proc{ |variant| variant.on_demand ? I18n.t(:on_demand) : variant.on_hand } + } + ) + end + def filter_on_hand(variants) variants # do not filter end