콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3286 화면

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


아바타
취소
베스트 답변


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)]



아바타
취소
작성자

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?

작성자 베스트 답변

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.

아바타
취소
관련 게시물 답글 화면 활동
0
3월 24
1270
3
6월 25
1179
1
10월 24
1858
2
10월 24
3206
1
7월 24
2451