Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How can I create a product in Python interactively?

By
Kasper Souren
on 7/14/14, 1:53 PM 965 views

I want to interactively create new product. I got as far as importing the addon:

python

import openerp

openerp.tools.config.parse_config(['--addons-path=addons'])

from openerp.addons.product import product

p = new product.product_product()

SyntaxError: invalid syntax

p = product.product_product()

type(p)

NoneType   # no luck here either

# And then there is...

product.product_product.create()

TypeError: unbound method create() must be called with product_product instance as first argument (got nothing instead)

# Ok I get that, but how do I create a product_product instance?

# And this one is not very clear either:

product.product_product.create_instance()

TypeError: create_instance() takes exactly 3 arguments (1 given)

# But the docstring is not very helpful.

 

 

 

0
Kasper Souren
On 8/1/14, 7:04 AM

Use ERPpeek:

models('product') # get a list of models that contain the word product

m = model('product.product')

p = m.create({ 'name': 'Test product' })

# p.unlink()  # If you want to remove your test product

 

See also this tutorial.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/14/14, 1:53 PM
Seen: 965 times
Last updated: 3/16/15, 8:10 AM