Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
6199 Widoki

i want to know how many stockable product in the order


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
2
sty 24
5421
0
cze 23
2024
1
gru 22
3334
0
kwi 22
2551
2
lip 25
3813