Filter Inventory Dimension values based on stock data

Set up

We have created Inventory Dimensions named Rack. When adding Purchase Receipt, we set the Rack value for every document.

What we need

How do we limit the Rack list to only show those Racks where the Item was actually stored during Purchase Receipt?

We’re having trouble in setting the Inventory Dimension mandatory for all stock transactions except for POS Invoice.

Here’s the screenshot of the created dimension:

What is the correct way to make the Rack Inventory Dimension mandatory for all documents except for POS Invoice?

Using frm.fields_dict['items'].grid.update_docfield_property('rack','reqd', 1) to solve the problem.

Found the solution in this answer