Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
3092 Prikazi

I have done a lot customisations using studio in Odoo 14. Now Im trying to add a column for Warehouse Location in stock.production.lot, but I can't figure out how to to this.


If I add a related field to: product_stock.quants_location.display_name I get the correct warehouse location if Qty=1. But if product Qty>1, warehouse location is displayed as Virtual Locations/Inventory adjustment.

Any idea how this could be solved?


//Rickard


Avatar
Opusti
Best Answer


Odoo uses the same stock.production.lot object for Lot and Serial Number. In case of serial number, it is normal that this serial number is located in one location at a time, but in the case of Lot inventory, it can be divided into different locations, and it is not possible to display multiple locations in a single field, that's why Odoo added a smart button (Location) in the Header section of form view. If the user clicks on the Location Smart button, he will know where the inventory is.

If you want to show all locations on the list/tree you need to create a custom field (many2many) which calculates the field it will check where the serial/lot number is stored and add those locations.


You can refer to the following code snippet


location_ids = fields.Many2many('stock.location', compute='_compute_locations', string="Location")

def _compute_locations(self):
for lot in self:
location_ids = self.env['stock.quant'].search([('lot_id', '=', lot.id), ('quantity', '>', 0), ('location_id.usage', '=', 'internal')]).mapped('location_id').ids
lot.location_ids = [(6, 0, location_ids)]



Avatar
Opusti
Avtor

Thanks Sagar.
If creating a many2many field, I get "No Records" for all Serial Number rows in tree view. I guess I need to configure the domain to get this done? Any idea how to configure the many2many field?

Hello Rickard Walster

I have updated the answer and provided you code snippet that shows how to add many2many calculated(compute) field that shows location

I'm trying to do this as well. Can this be done with Studio? If so, how?

Avtor Best Answer

Hello Sagar

Thanks you very much for your effort. However, it seems Im not skilled enough for this, and I don't have access to the server. Im only using Studio for customisations, so I don't really know how to configure the field using your code snippet.

I guess I should be able to create the field and configure it using studio and field settings, but I couldn't figure out how to.


PS. For clarification, each Serial Number is only located in one location, but since there are multiple Serial Numbers for a product, it gives different locations for each row in Lot/Serial tree view.

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
mar. 24
1134
3
jun. 25
942
1
okt. 24
1651
2
okt. 24
2981
1
jul. 24
2214