Hello
I want to filter the available lot numbers for particular products and customers. I have a model which holds the information what the rules are applicable for a combination of products and customers.
When clicking the "Check availablity" button on the picking Odoo will try to assign lots for a product based on the exit strategy. I need to be able to filter the possible lots based on the customer of the order and the product based on the rules that I defined in my own models.
I'm hooking into the _gather() method of the stock.quant model which generates a list of quant lines that can be used for a product. Although I have the product_id from the method arguments, I don't have the partner_id of the customer in that method. So I was looking to the self.context parameters but the results are quite unexpected. The context seems to depend from which screen you click through to the picking (from sale order, inventory, etc ...) and I don't always have a way to find the sale order for the picking in the context. If you go the Inventory > Delivery Orders and click on the "Check availability" button for a picking you get the information about the picking type in the context and not the information about the picking which is currently displaying.
How can I get the id of the picking which is currently being displayed in the form view when clicking the "Check availability" button?