跳至內容
選單
此問題已被標幟
1 回覆
6255 瀏覽次數

i want to know how many stockable product in the order


頭像
捨棄
最佳答案

Hi,

If you are looking to display/get the no of the stock-able product in the sale order, you can add a compute field in the sale order model and compute the count into it.

stock_product_count = fields.Integer(string='Count', compute='get_pro_count')


@api.multi
def get_pro_count(self):
for rec in self:
count = 0
for line in rec.order_line:
if line.product_id.type == 'product':
count += 1
rec.stock_product_count = count


Thanks

頭像
捨棄
作者

raise ValueError("Expected singleton: %s" % self)

ValueError: Expected singleton: sale.order(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)

Hope you have added the field in tree view also, you can update the code like this,

@api.multi

def get_pro_count(self):

for rec in self:

count = 0

for line in rec.order_line:

if line.product_id.type == 'product':

count += 1

rec.stock_product_count = count

相關帖文 回覆 瀏覽次數 活動
2
1月 24
5499
0
6月 23
2075
1
12月 22
3433
0
4月 22
2622
2
7月 25
3883