Skip to content

Commit

Permalink
When all Inventory Units are "picked", the Shipment gets "picked" sta…
Browse files Browse the repository at this point in the history
…te too
  • Loading branch information
kalkov committed Mar 26, 2012
1 parent fb02361 commit cbb4a4e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Expand Up @@ -3,12 +3,16 @@ module Admin
InventoryUnitsController.class_eval do

before_filter :load_inventory_unit , :only => [:fire]

respond_to :html

def fire
if @iu.send("#{params[:e]}")
flash.notice = t(:unit_picked)
if @iu.shipment.state == 'picked'
flash.notice = t(:shipment_is_picked)
else
flash.notice = t(:unit_picked)
end

else
flash[:error] = t(:cannot_perform_operation)
end
Expand Down
13 changes: 4 additions & 9 deletions app/models/spree/inventory_unit_decorator.rb
Expand Up @@ -33,23 +33,18 @@ def after_picked
end

def update_shipment_state
@shipment_state =
case shipment.inventory_units.count
when 0
nil
when shipment.inventory_units.picked.count
'picked'
puts "They are picked all"
if shipment.inventory_units.count == shipment.inventory_units.picked.count
self.shipment.update_attribute_without_callbacks('state', 'picked')
end

# self.shipment.update_attribute_without_callbacks('state', @shipment_state)

self.shipment.update_attribute('state', @shipment_state)
# self.state_changes.create({
# :previous_state => 'not_picked',
# :next_state => @shipment_state,
# :name => 'shipment',
# :user_id => (User.respond_to?(:current) && User.current && User.current.id) || self.user_id
# })

end

def not_packed?
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -40,6 +40,7 @@ en:
pick: "Pick"
picked: "Picked"
unit_picked: "Unit Picked"
shipment_is_picked: "Shipment is Picked"

picking_list: "Picking List"
picking_list_for_order: "Picking List for Order : "

0 comments on commit cbb4a4e

Please sign in to comment.