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

I want to take discount amount for a specific order in sale.order and display it on a tree view. I tried everything but I couldn't do it.

Can please someone help?

Awatar
Odrzuć
Najlepsza odpowiedź

Hi, The discount field in sale order line and for one order maybe you will have multi lines so you need to calculate all discount amount for each line, You can get the amount before discount in the field  amount_undiscounted and you can add it to the list view. But if you want to to get the total discount amount for the order you need to do your customization and add discount_total_amount to sale order model as computed field as below and then you can add it to the sale order tree view:

discount_total_amount = fields.Float('Discount Amount', compute='_compute_discount_amount', digits=0, store=True)


@api.multi
@api.depends('order_line.price_unit', 'order_line.discount', 'order_line.product_uom_qty')
def _compute_discount_amount(self):
for order in self:
total = 0.0
for line in order.order_line:
total += line.price_unit * ((line.discount or 0.0) / 100.0) * line.product_uom_qty
odrer.discount_total_amount = total

Awatar
Odrzuć
Najlepsza odpowiedź

Hello Ricky,

You have to create the tree view of sale order line. I think you can get discount from that.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
lis 23
17307
3
lis 24
24908
1
kwi 23
6062
2
gru 22
6789
1
lis 22
3974