Browse Source

extra script for epcollection to gen barcodes

chemi ledon 7 năm trước cách đây
mục cha
commit
e8197c8e8c
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      app/models/product.rb

+ 10 - 0
app/models/product.rb

@@ -462,4 +462,14 @@ class Product < ActiveRecord::Base
       product.save
     end
   end
+
+  def self.gen_only_barcodes_w_empty
+    products = Product.vigentes.where(barcode: '')
+    products.each do |product|
+      product.skip_sku_validation = true
+      product.barcode = format('%07d', product.id)
+      product.save
+    end
+    puts 'termine'
+  end
 end