In order to call the export_stock_level() method from the Odoo shell, you need to perform the following steps:
- Start the Odoo shell and specify your project configuration file:
$ ./odoo-bin shell -c project.conf --log-level=error
- Check for error messages and read the information text that's displayed before the usual Python command-line prompt:
env: <odoo.api.Environment object at 0x10e3277f0>
odoo: <module 'odoo' from '/home/parth/community/odoo/__init__.py'>
openerp: <module 'odoo' from '/home/parth/community/odoo/__init__.py'>
self: res.users(1,)
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 9.3.0] 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.