Hello all, I'm using OdooRpc to pull some data from the products template.
Expected behavior: I used to be able to do this...
def pricelist():
odoo = get_session()
p = odoo.env['product.template']
product_ids = p.search([('sale_ok', '=', True)], limit=10, offset=2)
products = p.browse(product_ids)
csv = ""
for p in products:
csv += str(p.categ_id.name) + "," + str(p.name) + "," + str(p.list_price) + "," + str(p.default_code) + "," + str(p.item_ids.fixed_price) + "," + str(p.qty_available) + "\n"
f = open("pricelist-auto.txt", "w")
f.write(csv)
This has stopped working. I'm using Odoo 11 Enterprise.
This is the error I get odoorpc.error.RPCError: Expected singleton: product.template(132,...)Next attempt: This is terribly inefficient but it worked a couple times...
def pricelist_2():
odoo = get_session()
p = odoo.env['product.template']
product_ids = p.search([('sale_ok', '=', True)])
csv = ""
for pro in product_ids:
p = odoo.env['product.template'].browse(pro)
csv += str(p.categ_id.name) + "," + str(p.name) + "," + str(p.list_price) + "," + str(p.default_code) + "," + str(p.item_ids.fixed_price) + "," + str(p.qty_available) + "\n"
f = open("pricelist-auto.txt", "w")
f.write(csv)
This take 20 minutes because there are like 2000 products. It still come up with the same error.
Mind you the first piece of code was working perfectly fine.
If there I fix for this or am I doing something wrong?
Thanks for any help you can provide.