Merge pull request #7228 from andrewpbrett/freeze-canceled-orders

Remove UI for modifying line items on canceled orders
This commit is contained in:
Matt-Yorkley
2021-03-29 15:24:24 +02:00
committed by GitHub
6 changed files with 28 additions and 9 deletions

View File

@@ -284,6 +284,10 @@ module Spree
I18n.t('shipping')
end
def can_modify?
!shipped? && !order.canceled?
end
private
def manifest_unstock(item)

View File

@@ -4,8 +4,11 @@
%fieldset.no-border-bottom
%legend{:align => "center"}= Spree.t(:add_product)
.field.twelve.columns.alpha{"data-hook" => "add_product_name"}
= label_tag :add_variant_id, Spree.t(:name_or_sku)
= hidden_field_tag :add_variant_id, "", :class => "variant_autocomplete fullwidth"
- if @order.canceled?
= t(".cannot_add_item_to_canceled_order")
- else
.field.twelve.columns.alpha{"data-hook" => "add_product_name"}
= label_tag :add_variant_id, Spree.t(:name_or_sku)
= hidden_field_tag :add_variant_id, "", :class => "variant_autocomplete fullwidth"
#stock_details

View File

@@ -33,7 +33,7 @@
%tbody{ "data-shipment-number" => "#{shipment.number}", "data-order-number" => "#{order.number}" }
= render 'spree/admin/orders/shipment_manifest', order: order, shipment: shipment
- unless shipment.shipped?
- if shipment.can_modify?
%tr.edit-method.hidden.total
%td{ :colspan => "5" }
%div.field.alpha.five.columns
@@ -69,7 +69,7 @@
%span
= shipment.fee_adjustment.display_amount
- if shipment.fee_adjustment.present? && !shipment.shipped?
- if shipment.fee_adjustment.present? && shipment.can_modify?
%td.actions
- if can? :update, shipment
= link_to '', '', :class => 'edit-method icon_link icon-edit no-text with-tip', :data => { :action => 'edit' }, :title => Spree.t('edit')
@@ -81,7 +81,7 @@
= text_field_tag :tracking, shipment.tracking
%td.actions
- if can? :update, shipment
- if can?(:update, shipment) && !shipment.canceled?
= link_to '', '', :class => 'save-tracking icon_link icon-ok no-text with-tip', :data => { 'shipment-number' => shipment.number, :action => 'save' }, :title => I18n.t('actions.save')
= link_to '', '', :class => 'cancel-tracking icon_link icon-cancel no-text with-tip', :data => { :action => 'cancel' }, :title => I18n.t('actions.cancel')
@@ -95,5 +95,5 @@
= Spree.t(:no_tracking_present)
%td.actions
- if can? :update, shipment
- if can?(:update, shipment) && shipment.can_modify?
= link_to '', '', :class => 'edit-tracking icon_link icon-edit no-text with-tip', :data => { :action => 'edit' }, :title => Spree.t('edit')

View File

@@ -19,7 +19,7 @@
= line_item_shipment_price(line_item, item.quantity)
%td.cart-item-delete.actions{ "data-hook" => "cart_item_delete" }
- if !shipment.shipped? && can?(:update, shipment)
- if shipment.can_modify? && can?(:update, shipment)
= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('actions.save'), :style => 'display: none'
= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('actions.cancel'), :style => 'display: none'
= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('actions.edit')

View File

@@ -3326,6 +3326,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using
received: "Received"
canceled: "Canceled"
orders:
add_product:
cannot_add_item_to_canceled_order: "Cannot add item to canceled order"
index:
listing_orders: "Listing Orders"
new_order: "New Order"

View File

@@ -343,6 +343,16 @@ feature '
end
end
end
context "and the order has been canceled" do
it "does not allow modifying line items" do
order.cancel!
visit spree.edit_admin_order_path(order)
within("tr.stock-item", text: order.products.first.name) do
expect(page).to_not have_selector("a.edit-item")
end
end
end
end
scenario "creating an order with distributor and order cycle" do