Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
6952 Переглядів

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.

 

 

 

Аватар
Відмінити
Автор Найкраща відповідь

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.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
бер. 25
1529
4
квіт. 24
174410
0
груд. 23
2296
5
лип. 25
228609
1
груд. 22
3439