Create a new url /orders/ORDER_ID/distribution

That handles the step when distributor and order_cycle must be selected
This commit is contained in:
Jean-Baptiste Bellet
2023-04-17 17:18:22 +02:00
parent 8ad4d2cc2e
commit 73a81310f8
3 changed files with 8 additions and 4 deletions

View File

@@ -9,8 +9,8 @@ module Spree
helper CheckoutHelper
before_action :load_order, only: [:edit, :update, :fire, :resend,
:invoice, :print]
before_action :load_distribution_choices, only: [:new, :edit, :update]
:invoice, :print, :set_distribution]
before_action :load_distribution_choices, only: [:new, :edit, :update, :set_distribution]
# Ensure that the distributor is set for an order when
before_action :ensure_distribution, only: :new
@@ -21,10 +21,13 @@ module Spree
def new
@order = Order.create
@order.created_by = spree_current_user
@order.generate_order_number
@order.save
redirect_to spree.edit_admin_order_url(@order)
redirect_to spree.distribution_admin_order_path(@order)
end
def set_distribution; end
def edit
@order.shipments.map(&:refresh_rates)

View File

@@ -274,7 +274,7 @@ module Spree
# Enterprise User can access orders that are placed inside a OC they coordinate
order.order_cycle&.coordinated_by?(user)
end
can [:admin, :bulk_management, :managed], Spree::Order do
can [:admin, :bulk_management, :managed, :set_distribution], Spree::Order do
user.admin? || user.enterprises.any?(&:is_distributor)
end
can [:admin, :create, :show, :poll], :invoice

View File

@@ -89,6 +89,7 @@ Spree::Core::Engine.routes.draw do
post :resend
get :invoice
get :print
get :distribution, to: 'orders#set_distribution'
end
collection do