Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6310 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
Merge Same Item in Sale Order Line แก้ไขแล้ว
2
ม.ค. 24
5601
0
มิ.ย. 23
2133
1
ธ.ค. 22
3518
0
เม.ย. 22
2695
2
ก.ค. 25
3972