2011-05-07 20:50:39 +02:00
|
|
|
class SharedSupplier < ActiveRecord::Base
|
|
|
|
|
|
|
|
# connect to database from sharedLists-Application
|
2012-08-24 19:52:38 +02:00
|
|
|
SharedSupplier.establish_connection(FoodsoftConfig[:shared_lists])
|
2011-05-07 20:50:39 +02:00
|
|
|
# set correct table_name in external DB
|
2012-10-19 01:12:47 +02:00
|
|
|
self.table_name = 'suppliers'
|
|
|
|
|
2013-06-04 11:28:25 +02:00
|
|
|
has_many :suppliers
|
2011-05-07 20:50:39 +02:00
|
|
|
has_many :shared_articles, :foreign_key => :supplier_id
|
2013-06-09 18:02:47 +02:00
|
|
|
|
|
|
|
# These set of attributes are used to autofill attributes of new supplier,
|
|
|
|
# when created by import from shared supplier feature.
|
|
|
|
def autofill_attributes
|
|
|
|
whitelist = %w(name address phone fax email url delivery_days note)
|
|
|
|
attributes.select { |k,_v| whitelist.include?(k) }
|
|
|
|
end
|
2011-05-07 20:50:39 +02:00
|
|
|
end
|
|
|
|
|