I am trying to read the stock levels of each product in a location with JSON-RPC but I have no idea how to do it. My RPC connection works otherwise, so that I can create Parties, Products and so on.
I should probably call the search method on stock.products_by_locations and generate the right context with stock.products_by_locations.context first to add the dates and append location ids. But I even fail to find the right method in stock.products_by_locations.context since its a ModelView.
Can someone please give me a hint in the right direction, because I am completely lost right now.
If you are reading stock levels by JSON-RPC you should sarch on the model stock.products_by_locations but filling the context (last argument of your dicht) with the following fields:
locations: list of ids of the locations you want to read the stock from
company: id of the company you want to read the stock from
stock_date_end: The date for which the stock quantity is calculated. An empty value calculates as far ahead as possible. A date in the past will provide historical values.
When you see a context model in a view in tryton code, this means that the fields of this models will be set to update the requests context. Normally this is done for models that compute values and the context values are used to alter the computed result.