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