Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4493 Lượt xem

```

for product in self.env['product.product'].search([('type','=','product'),('sale_ok','=',True)]):

product_qty_available = self.env['product.product'].browse(product.id) 

 qty_available = product_qty_available.with_context({'to_date': last_date_of_month,'company_id':comp_id}).qty_available

```

this query return me current company data not user selection company data 

where i'm wrong

what will i use sudo or else or is it possible or not ? 

note comp_id is user selected company id 



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Usman,

You can get the qty by the location of the Other Company's Warehouse.

1) Search the WH of the Other Company

2) Search the Stock Location(s) of the Other WH

3) Pass the location in the context: "self.with_context({'location': location_id})"

Hope this will help you.

Ảnh đại diện
Huỷ bỏ
Tác giả

your idea is working just one point i'm lack...pls correct me

warehouse_id = self.env['stock.warehouse'].sudo().search([('company_id','=',comp_id)],limit=1).id

its give me correct id when i select my own company other company when i select its give me false value why ?

Tác giả

your answer is very close to accpt pls review my last query

Make sure other WH has other company set in the Company field.

I think all of your WHs have single company selected. Please double check that and set the other company and then it will work.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 21
7287
1
thg 12 19
2883
3
thg 7 24
2135
3
thg 11 23
17520
3
thg 11 24
25160