Fix copy operation for stock orders
Stock orders have the supplier_id set to zero, which will be ignored in the url-method by rails. Only use the order_id to fix this.
This commit is contained in:
parent
3a4519757e
commit
d73c206e29
3 changed files with 11 additions and 4 deletions
|
|
@ -60,8 +60,15 @@ class OrdersController < ApplicationController
|
|||
|
||||
# Page to create a new order.
|
||||
def new
|
||||
@order = Order.new(supplier_id: params[:supplier_id]).init_dates
|
||||
@order.article_ids = Order.find(params[:order_id]).article_ids if params[:order_id]
|
||||
if params[:order_id]
|
||||
old_order = Order.find(params[:order_id])
|
||||
@order = Order.new(supplier_id: old_order.supplier_id).init_dates
|
||||
@order.article_ids = old_order.article_ids
|
||||
else
|
||||
@order = Order.new(supplier_id: params[:supplier_id]).init_dates
|
||||
end
|
||||
rescue => error
|
||||
redirect_to orders_url, alert: t('errors.general_msg', msg: error.message)
|
||||
end
|
||||
|
||||
# Save a new order.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue