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

I created a custom field in sale.order.line


_inherit = "sale.order.line"


maximum_quantity = fields.Float (string = 'Maximum Quantity', default = check_max_quan)


# then i called this method to fetch product available quantity and pass it to maximum quantity by default

def check_max_quan (self):

max_quan = self.env ['product.template']. search ([['product_id', '=', self.product_id]]). qty_available
return max_quan



# But this logic is not working i am unable to pass qty_available value of product to my custom created field

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

Hi Mayank,


try the below solution to get Available Qty of Product from the Main Stock

>> product_id = self.env ['product.template']. search ([['product_id', '=', self.product_id]]) 

>> max_quan = product_id.with_context(
location=line.order_id.warehouse_id.lot_stock_id.id,
warehouse_id=line.order_id.warehouse_id.id
).qty_available


Thanks & Regards,

Sunny Sheth

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 8 21
3890
1
thg 4 24
4526
2
thg 9 23
4587
0
thg 2 22
2564
1
thg 6 21
5646