I am working on a python import-script to import data from an xls sheet to odooErp. In the script, there is information like "name", "if it is a bom list" and (important) for "prices" for different pricelists (in this case p1-p4).
I am using the following versions: Odoo: Community v.12 python: v. 3.7.6 odoorpc: 0.7.0
My script is already able to find the products in the odoodb, take some of the xls-data and writes it to the product in the odoodb. These are field like name, price (which is the standard price), type, etc. (standard rpc calls) But I was not able to manage writing the product to a pricelist or to assign a pricelist to the product. I did not found any documentation about this step on how to manage the syntax for solving this. So I tried to do this:
PricelistModel = odoo.env['product.pricelist']
pricelist = PricelistModel.search([('name', '=', 'p1')], limit=1)
if pricelist:
p = PricelistModel.browse(pricelist)
item = {
'applied_on': '1_product',
'product_tmpl_id': product['id'], #<-- this is int also tried string
'compute_price': 'fixed',
'fixed_price': float(row[3]) #<--- this is int also tried string
}
p.write({
'item_ids':
item
})
Unfortunately even with no errors shown and receiving a "True" from the function this call is not successful and is doing nothing.
Now my questions are:
I want to do more with that odoorpc, but the documentation is way to short and not even scratching the surface of all the possibilities I could imagine to do. -> is there a way to print out the answer why odoo isn't writing to the DB so I could teach myself how to "talk" with odoo?
Does anyone know a solution to get this problem solved?
Cheers and thank you very much for your time :)
try this code:
you can read https://www.odoo.com/documentation/13.0/reference/orm.html#create-update as reference for One2many special command