How it works...

Step 3 calls self.with_context() with some keyword arguments. This returns a new version of self (which is a product.product recordset) with the keys added to the
current context. We are adding two keys:

  • location: This one is mentioned in the docstring of the product.product method computing the qty_available field.
  • active_test: When this key is present and linked to the False value, the search() method does not automatically add ('active', '=', True) to the search domain. Using this ensures that in step 4, we get all the products, including the disabled ones.

When we read the value of product.qty_available in step 5, the computation of that field is made using only the specified stock location.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.39.142