@@ -16,6 +16,7 @@ class CrossoveredBudgetLines(models.Model):
1616
1717 def _compute_committ_uncommitt_amount (self ):
1818 purchase_line_obj = self .env ["purchase.order.line" ]
19+ company_currency = self .company_id .currency_id
1920 for budget_line in self :
2021 commit_domain = [
2122 ("date_order" , ">=" , budget_line .date_from ),
@@ -40,15 +41,35 @@ def _compute_committ_uncommitt_amount(self):
4041 if budget_line .crossovered_budget_id .amount_include_tax :
4142 budget_line .committed_amount = - sum (
4243 [
43- line .price_unit * (line .product_qty - line .qty_invoiced )
44- + line .price_tax
44+ line .currency_id ._convert (
45+ line .price_unit ,
46+ company_currency ,
47+ self .company_id ,
48+ line .date_order ,
49+ round = False ,
50+ )
51+ * (line .product_qty - line .qty_invoiced )
52+ + line .currency_id ._convert (
53+ line .price_tax ,
54+ company_currency ,
55+ self .company_id ,
56+ line .date_order ,
57+ round = False ,
58+ )
4559 for line in po_lines_commimt
4660 ]
4761 )
4862 else :
4963 budget_line .committed_amount = - sum (
5064 [
51- line .price_unit * (line .product_qty - line .qty_invoiced )
65+ line .currency_id ._convert (
66+ line .price_unit ,
67+ company_currency ,
68+ self .company_id ,
69+ line .date_order ,
70+ round = False ,
71+ )
72+ * (line .product_qty - line .qty_invoiced )
5273 for line in po_lines_commimt
5374 ]
5475 )
@@ -74,11 +95,36 @@ def _compute_committ_uncommitt_amount(self):
7495 po_lines_uncommit = purchase_line_obj .search (uncommit_domain )
7596 if budget_line .crossovered_budget_id .amount_include_tax :
7697 budget_line .uncommitted_amount = - sum (
77- [line .price_subtotal + line .price_tax for line in po_lines_uncommit ]
98+ [
99+ line .currency_id ._convert (
100+ line .price_subtotal ,
101+ company_currency ,
102+ self .company_id ,
103+ line .date_order ,
104+ round = False ,
105+ )
106+ + line .currency_id ._convert (
107+ line .price_tax ,
108+ company_currency ,
109+ self .company_id ,
110+ line .date_order ,
111+ round = False ,
112+ )
113+ for line in po_lines_uncommit
114+ ]
78115 )
79116 else :
80117 budget_line .uncommitted_amount = - sum (
81- [line .price_subtotal for line in po_lines_uncommit ]
118+ [
119+ line .currency_id ._convert (
120+ line .price_subtotal ,
121+ company_currency ,
122+ self .company_id ,
123+ line .date_order ,
124+ round = False ,
125+ )
126+ for line in po_lines_uncommit
127+ ]
82128 )
83129
84130 def _compute_over_budget (self ):
0 commit comments