Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
1319 Weergaven

Hello,


In the inventory module, when I make a delivery, I would like the list of locations available for transferring goods to include only those that contain the product in question.


My store has around 100 locations, and it's difficult for my staff to remember which location each product is in. 


So, when they make a delivery, they either have to physically go into the store to see where the product was taken from (which is not at all optimal), or check the list of locations in which the product is stored, from the product sheet, which is not ideal either.


I'd therefore like the delivery interface to show, when they select a product to be delivered, the list of selectable locations to include only those containing the product just selected. Naturally, if there are only two or three left, they'll be in a much better position to choose.


I tried to use a domain to create this filter, based on the 'Qty → product_id' field accessible from 'location_id', but I couldn't do it. I'm on Odoo online with Odoo Studio, so I have some customization possibilities, but they're not very extensive either.


Does anyone have a solution to my problem?


Thank you in advance, and I'll be happy to talk to you.

Avatar
Annuleer
Beste antwoord

Hi Robin,

You can achieve this functionality by creating a custom computed field in the stock.picking model and applying a domain on the location_id field based on the computed field.

Here are the steps to follow:

  1. Open Studio mode on the stock.picking model and add a new computed field.
  2. Choose "Many2many" as the field type and name it available_locations.
  3. In the "Relation" field, select stock.location (or the model name for the locations).
  4. In the "Compute" section, add a compute function like this:
Quant = self.env['stock.quant']
for record in self:
    if record.product_id:
        quants = Quant.search([('product_id', '=', record.product_id.id), ('quantity', '>', 0)])
        record['available_locations'] = quants.mapped('location_id')
    else:
        record['available_locations'] = False
  1. Set the dependent field as product_id.
  2. After creating the computed field, proceed to apply a domain on the location_id field like so:
[("id", "ilike", "available_locations.ids")]

This method should meet your requirements.


Hope it helps

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
aug. 24
1058
0
sep. 19
2647
0
jan. 24
1468
3
dec. 22
4360
2
mei 19
3037