Permalink
Browse files

When all Inventory Units are "picked", the Shipment gets "picked" sta…

…te too
  • Loading branch information...
1 parent fb02361 commit cbb4a4e5abe10a69dec93d82a90da434b0c68526 @kalkov kalkov committed Mar 26, 2012
@@ -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
@@ -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?
View
@@ -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.