Add print and capture permission for orders

This commit is contained in:
wandji20
2024-10-29 11:11:51 +01:00
parent 0b9724fbdb
commit 696c42cba4
2 changed files with 4 additions and 9 deletions

View File

@@ -8,10 +8,10 @@ module Spree
include OpenFoodNetwork::SpreeApiKeyLoader
helper CheckoutHelper
before_action :load_order, only: [:edit, :update, :fire, :resend, :invoice, :print]
before_action :load_order,
only: [:edit, :update, :fire, :resend, :invoice, :print, :capture, :ship]
before_action :load_distribution_choices, only: [:new, :create, :edit, :update]
before_action :require_distributor_abn, only: :invoice
before_action :authorize_order, only: [:capture, :ship]
def index
orders = SearchOrders.new(search_params, spree_current_user).orders
@@ -125,7 +125,6 @@ module Spree
def ship
@order.send_shipment_email = false unless params[:send_shipment_email]
@order.send_shipment_email
if @order.ship
if params[:current_page] != 'index'
return redirect_back fallback_location: admin_orders_path
@@ -263,11 +262,6 @@ module Spree
authorize! action, @order
end
def authorize_order
@order = Spree::Order.find_by(number: params[:id])
authorize! :admin, @order
end
def set_param_for_controller
redirect_back fallback_location: admin_orders_path
params[:id] = @order.number

View File

@@ -266,7 +266,8 @@ module Spree
def add_order_management_abilities(user)
can [:index, :create], Spree::Order
can [:read, :update, :fire, :resend, :invoice, :print], Spree::Order do |order|
can [:read, :update, :fire, :resend, :invoice, :print, :ship, :capture],
Spree::Order do |order|
# We allow editing orders with a nil distributor as this state occurs
# during the order creation process from the admin backend
order.distributor.nil? ||