Fixed bug when adding new article to a stock order (balancing

controller)
This commit is contained in:
Benjamin Meichsner 2009-09-07 10:57:49 +02:00
parent 8912dbaea0
commit a1ca9f368d

View file

@ -79,15 +79,18 @@ class Finance::BalancingController < ApplicationController
def auto_complete_for_article_name def auto_complete_for_article_name
order = Order.find(params[:order_id]) order = Order.find(params[:order_id])
type = order.stockit? ? "type = 'StockArticle'" : "type IS NULL" find_params = {
@articles = Article.find(:all, :conditions => ["LOWER(articles.name) LIKE ?", "%#{params[:article][:name].downcase}%" ],
:conditions => [ "supplier_id = ? AND #{type} AND LOWER(name) LIKE ?", :order => 'articles.name ASC',
order.supplier_id, :limit => 8
'%' + params[:article][:name].downcase + '%' ], }
:order => 'name ASC', @articles = if order.stockit?
:limit => 8) StockArticle.all find_params
render :partial => 'shared/auto_complete_articles' else
order.supplier.articles.all find_params
end
render :partial => 'shared/auto_complete_articles'
end end
def create_order_article def create_order_article