Add custom fields to invoice, odergroup, supplier and user
This commit is contained in:
parent
72b5a5ca82
commit
75deec9f06
13 changed files with 48 additions and 7 deletions
16
app/models/concerns/custom_fields.rb
Normal file
16
app/models/concerns/custom_fields.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
module CustomFields
|
||||
extend ActiveSupport::Concern
|
||||
include RailsSettings::Extend
|
||||
|
||||
attr_accessor :custom_fields
|
||||
|
||||
included do
|
||||
after_initialize do
|
||||
settings.defaults['custom_fields'] = { } unless settings.custom_fields
|
||||
end
|
||||
|
||||
after_save do
|
||||
self.settings.custom_fields = custom_fields if custom_fields
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
class Invoice < ActiveRecord::Base
|
||||
include CustomFields
|
||||
|
||||
belongs_to :supplier
|
||||
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
# Ordergroup have the following attributes, in addition to Group
|
||||
# * account_balance (decimal)
|
||||
class Ordergroup < Group
|
||||
include CustomFields
|
||||
|
||||
APPLE_MONTH_AGO = 6 # How many month back we will count tasks and orders sum
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# encoding: utf-8
|
||||
class Supplier < ActiveRecord::Base
|
||||
include MarkAsDeletedWithName
|
||||
include CustomFields
|
||||
|
||||
has_many :articles, -> { where(:type => nil).includes(:article_category).order('article_categories.name', 'articles.name') }
|
||||
has_many :stock_articles, -> { includes(:article_category).order('article_categories.name', 'articles.name') }
|
||||
|
|
@ -10,7 +11,7 @@ class Supplier < ActiveRecord::Base
|
|||
belongs_to :shared_supplier # for the sharedLists-App
|
||||
|
||||
include ActiveModel::MassAssignmentSecurity
|
||||
attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number, :iban,
|
||||
attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number, :iban, :custom_fields,
|
||||
:delivery_days, :order_howto, :note, :shared_supplier_id, :min_order_quantity, :shared_sync_method
|
||||
|
||||
validates :name, :presence => true, :length => { :in => 4..30 }
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
require 'digest/sha1'
|
||||
# specific user rights through memberships (see Group)
|
||||
class User < ActiveRecord::Base
|
||||
include RailsSettings::Extend
|
||||
include CustomFields
|
||||
#TODO: acts_as_paraniod ??
|
||||
|
||||
|
||||
has_many :memberships, :dependent => :destroy
|
||||
has_many :groups, :through => :memberships
|
||||
#has_one :ordergroup, :through => :memberships, :source => :group, :class_name => "Ordergroup"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# encoding: utf-8
|
||||
class Workgroup < Group
|
||||
|
||||
include CustomFields
|
||||
|
||||
has_many :tasks
|
||||
# returns all non-finished tasks
|
||||
has_many :open_tasks, -> { where(:done => false).order('due_date', 'name') }, :class_name => 'Task'
|
||||
|
|
@ -25,6 +26,5 @@ class Workgroup < Group
|
|||
errors.add(:role_admin, I18n.t('workgroups.error_last_admin_role'))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue