SHOW:
|
|
- or go back to the newest paste.
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 | - | ProductCategory = Model.get('product.category') |
10 | + | Product = Model.get('product.product') |
11 | - | category, = ProductCategory.find([('name', '=', 'OTROS')]) |
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 | - | Product = Model.get('product.product') |
22 | + | |
23 | - | product = Product() |
23 | + | pt = ProductTemplate() |
24 | - | product.name = 'HEIDELBERG' |
24 | + | pt.name = 'this is a test' |
25 | - | product.category = category |
25 | + | pt.list_price = Decimal('5') |
26 | - | product.default_uom = unit |
26 | + | pt.cost_price = Decimal('5') |
27 | - | product.type = 'service' |
27 | + | pt.category = category |
28 | - | product.purchasable = False |
28 | + | pt.default_uom = unit |
29 | - | product.salable = True |
29 | + | pt.type = 'goods' |
30 | - | product.list_price = Decimal('55') |
30 | + | pt.purchasable = True |
31 | - | product.cost_price = Decimal('55') |
31 | + | pt.salable = True |
32 | - | product.cost_price_method = 'fixed' |
32 | + | pt.account_category = True |
33 | - | product.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() |