@@ -9,24 +9,44 @@ class SaleOrder(models.Model):
99 _inherit = 'sale.order'
1010
1111 discount_total = fields .Monetary (
12- compute = '_compute_discount ' ,
12+ compute = '_compute_discount_total ' ,
1313 string = 'Discount Subtotal' ,
1414 currency_field = 'currency_id' ,
1515 store = True )
16+ price_subtotal_no_discount = fields .Monetary (
17+ compute = '_compute_discount_total' ,
18+ string = 'Subtotal Without Discount' ,
19+ currency_field = 'currency_id' ,
20+ store = True ,
21+ )
1622 price_total_no_discount = fields .Monetary (
17- compute = '_compute_discount ' ,
23+ compute = '_compute_discount_total ' ,
1824 string = 'Subtotal Without Discount' ,
1925 currency_field = 'currency_id' ,
2026 store = True )
2127
22- @api .depends ('order_line.discount_total' ,
23- 'order_line.price_total_no_discount' )
24- def _compute_discount (self ):
28+ @api .model
29+ def _get_compute_discount_total_depends (self ):
30+ return [
31+ 'order_line.discount_total' ,
32+ 'order_line.price_subtotal_no_discount' ,
33+ 'order_line.price_total_no_discount' ,
34+ ]
35+
36+ @api .depends (lambda self : self ._get_compute_discount_total_depends ())
37+ def _compute_discount_total (self ):
2538 for order in self :
2639 discount_total = sum (order .order_line .mapped ('discount_total' ))
40+ price_subtotal_no_discount = sum (
41+ order .order_line .mapped ('price_subtotal_no_discount' )
42+ )
2743 price_total_no_discount = sum (
28- order .order_line .mapped ('price_total_no_discount' ))
29- order .update ({
30- 'discount_total' : discount_total ,
31- 'price_total_no_discount' : price_total_no_discount
32- })
44+ order .order_line .mapped ('price_total_no_discount' )
45+ )
46+ order .update (
47+ {
48+ 'discount_total' : discount_total ,
49+ 'price_subtotal_no_discount' : price_subtotal_no_discount ,
50+ 'price_total_no_discount' : price_total_no_discount ,
51+ }
52+ )
0 commit comments