[tryton] proteus import

2011-12-08 Thread Mariano DAngelo
I'm trying to import a list of products, and I having trouble saving
product cost_price  I see it's stored in ir_property table
but I cannot save it as product.cost_price, how it most be done?

My saving fuction...

def append_product(name, code, st_cat,cost_price):
Product = Model.get('product.product')
product = Product()
#using unit as default uom
uom = Model.get('product.uom')
(um,) = uom.find([('name', '=', 'Unit')])
product.default_uom = um

product.active = True
product.account_category = True
product.taxes_category = True
product.purchasable = True
product.salable = True

product.code = '%s' %code
product.name = '%s' %name

#searching category
cat = Model.get('product.category')
(ca,) = cat.find([('name', '=', st_cat)])
product.category = ca

product.save()

-- 
tryton@googlegroups.com mailing list


Re: [tryton] proteus import

2011-12-08 Thread Nicolas Évrard
* Mariano DAngelo  [2011-12-08 04:56 +0100]: 


Hello,


I'm trying to import a list of products, and I having trouble saving
product cost_price  I see it's stored in ir_property table
but I cannot save it as product.cost_price, how it most be done?


You must assign to product.cost_price a decimal value (not a float).


def append_product(name, code, st_cat,cost_price):
   Product = Model.get('product.product')
   product = Product()
   #using unit as default uom
   uom = Model.get('product.uom')
   (um,) = uom.find([('name', '=', 'Unit')])
   product.default_uom = um

   product.active = True
   product.account_category = True
   product.taxes_category = True
   product.purchasable = True
   product.salable = True

   product.code = '%s' %code
   product.name = '%s' %name

   #searching category
   cat = Model.get('product.category')
   (ca,) = cat.find([('name', '=', st_cat)])
   product.category = ca

   product.save()


There is no assignation to product.cost_price is it normal ?

--
Nicolas Évrard

B2CK SPRL
rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
E-mail/Jabber: nicolas.evr...@b2ck.com
Website: http://www.b2ck.com/

--
tryton@googlegroups.com mailing list