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 InventoryUnitsController.class_eval do


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

respond_to :html respond_to :html


def fire def fire
if @iu.send("#{params[:e]}") 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 else
flash[:error] = t(:cannot_perform_operation) flash[:error] = t(:cannot_perform_operation)
end 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 end


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

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


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

end end


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


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

0 comments on commit cbb4a4e

Please sign in to comment.