This commit is contained in:
Nicolas Bally 2020-03-09 09:35:58 +01:00
parent 2c09c5decb
commit b97e5612d0
2 changed files with 11 additions and 3 deletions

View File

@ -25,7 +25,7 @@ class MOdrRep < ApplicationRecord
has_many :m_odr_files, :dependent => :destroy has_many :m_odr_files, :dependent => :destroy
accepts_nested_attributes_for :m_odr_files, :allow_destroy => true accepts_nested_attributes_for :m_odr_files, :allow_destroy => true
validates :m_odr_product_cat_id, :presence => true, :if => :product_cat_needed?
validates :qte, :presence => true validates :qte, :presence => true
validates :m_odr_product_id, :presence => true validates :m_odr_product_id, :presence => true
@ -37,6 +37,14 @@ class MOdrRep < ApplicationRecord
def product_cat_needed?
if self.m_odr.m_odr_product_cats.count > 0
true
else
false
end
end
def rgpd_needed? def rgpd_needed?
if self.m_odr and self.m_odr.confirm_case_needed if self.m_odr and self.m_odr.confirm_case_needed
true true

View File

@ -128,7 +128,7 @@
-if f.object.m_odr.m_odr_product_cats.count > 0 -if f.object.m_odr.m_odr_product_cats.count > 0
=f.inputs do =f.inputs do
=f.input :m_odr_product_cat_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Types :")), :as => :select, :collection => f.object.m_odr.m_odr_product_cats.order("id ASC"), :member_label => :name, :include_blank => false =f.input :m_odr_product_cat_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Types :")), :as => :select, :collection => f.object.m_odr.m_odr_product_cats.order("id ASC"), :member_label => :name, :include_blank => true, :prompt => (@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Nombre de pneus")
=f.inputs do =f.inputs do