Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import csv
- import sys
- from decimal import Decimal
- from proteus import config, Model, Wizard
- products = csv.reader(open('products.csv', 'r'))
- config = config.set_trytond('Toteko', database_type='postgresql', config_file='/opt/tryton/28/trytond.conf')
- Product = Model.get('product.product')
- ProductTemplate = Model.get('product.template')
- Category = Model.get('product.category')
- ProductUom = Model.get('product.uom')
- category, = Category.find([('name', '=', 'OTROS')])
- unit, = ProductUom.find([('symbol', '=', 'u')])
- def LoadProducts ():
- header=True
- for line in products:
- # Skip the header
- if not header:
- pt = ProductTemplate()
- pt.name = 'this is a test'
- pt.list_price = Decimal('5')
- pt.cost_price = Decimal('5')
- pt.category = category
- pt.default_uom = unit
- pt.type = 'goods'
- pt.purchasable = True
- pt.salable = True
- pt.account_category = True
- pt.taxes_category = True
- pt.save()
- product = Product(template=pt)
- product.save()
- header=False
- if __name__ == "__main__":
- LoadProducts()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement