コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4960 ビュー

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

アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
3
8月 21
3918
1
4月 24
4537
2
9月 23
4602
0
2月 22
2568
1
6月 21
5660