Advertisement
Guest User

Untitled

a guest
Jun 21st, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import csv
  3. import sys
  4. from decimal import Decimal
  5. from proteus import config, Model, Wizard
  6.  
  7. products = csv.reader(open('products.csv', 'r'))
  8. config = config.set_trytond('Toteko', database_type='postgresql', config_file='/opt/tryton/28/trytond.conf')
  9.  
  10. Product = Model.get('product.product')
  11. ProductTemplate = Model.get('product.template')
  12. Category = Model.get('product.category')
  13. ProductUom = Model.get('product.uom')
  14.  
  15. category, = Category.find([('name', '=', 'OTROS')])
  16. unit, = ProductUom.find([('symbol', '=', 'u')])
  17.  
  18. def LoadProducts ():
  19.   header=True
  20.   for line in products:
  21.     # Skip the header
  22.     if not header:
  23.       pt = ProductTemplate()
  24.       pt.name = 'this is a test'
  25.       pt.list_price = Decimal('5')
  26.       pt.cost_price = Decimal('5')
  27.       pt.category = category
  28.       pt.default_uom = unit
  29.       pt.type = 'goods'
  30.       pt.purchasable = True
  31.       pt.salable = True
  32.       pt.account_category = True
  33.       pt.taxes_category = True
  34.       pt.save()
  35.      
  36.       product = Product(template=pt)
  37.       product.save()
  38.    
  39.     header=False
  40.  
  41. if __name__ == "__main__":
  42.   LoadProducts()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement