kaps_app/app/models/p_sheet_line_line.rb
Nicolas Bally d60301e8a7 initial
2019-01-21 01:15:10 +01:00

46 lines
837 B
Ruby

class PSheetLineLine < ActiveRecord::Base
belongs_to :p_sheet_line
belongs_to :p_product_stock
belongs_to :p_size
belongs_to :p_color
def p_size
if self.p_size_id
PSize.where(:id => self.p_size_id).first
else
self.p_product_stock.p_size
end
end
def p_color
if self.p_color_id
PColor.where(:id => self.p_color_id).first
else
self.p_product_stock.p_color
end
end
def fige
if self.p_product_stock.p_color
p_color = self.p_product_stock.p_color.dup
p_color.archived = true
self.p_color = p_color
end
if self.p_product_stock.p_size
p_size = self.p_product_stock.p_size.dup
p_size.archived = true
self.p_size = p_size
end
self.ok_code = self.p_product_stock.code
end
end