Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
6225 Weergaven

i want to know how many stockable product in the order


Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Auteur

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

Gerelateerde posts Antwoorden Weergaven Activiteit
2
jan. 24
5454
0
jun. 23
2048
1
dec. 22
3371
0
apr. 22
2595
2
jul. 25
3852