In order to call the export_stock_level() method from the Odoo shell, you need to perform the following steps:
- Start the Odoo shell specifying your project configuration file:
$ ./odoo-bin shell -c project.conf --log-level=error
- Check for error messages, and read the information text displayed before the usual Python command-line prompt:
env: <odoo.api.Environment object at 0x7fac2ac2d990>
odoo: <module 'odoo' from '/home/cookbook/odoo/odoo/__init__.pyc'>
openerp: <module 'odoo' from '/home/cookbook/odoo/odoo/__init__.pyc'>
self: res.users(1,)
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
- Get a recordset for product.product:
>>> product = env['product.product']
- Get the main stock location record:
>>> location_stock = env.ref('stock.stock_location_stock')
- Call the export_stock_level() method:
>>> product.export_stock_level(location_stock)
- Commit the transaction before exiting:
>>> env.cr.commit()
- Exit the shell by pressing Ctrl + D