@@ -142,10 +142,11 @@ def _generate_report_content(self, workbook, report, data, report_data):
142
142
analytic_data = res_data ["analytic_data" ]
143
143
filter_partner_ids = res_data ["filter_partner_ids" ]
144
144
foreign_currency = res_data ["foreign_currency" ]
145
+ company_currency = res_data ["company_currency" ]
145
146
# For each account
146
147
for account in general_ledger :
147
148
# Write account title
148
- total_bal_curr = account [ "init_bal" ]. get ( "bal_curr" , 0 )
149
+ total_bal_curr = 0
149
150
self .write_array_title (
150
151
account ["code" ] + " - " + accounts_data [account ["id" ]]["name" ],
151
152
report_data ,
@@ -163,7 +164,7 @@ def _generate_report_content(self, workbook, report, data, report_data):
163
164
"initial_balance" : account ["init_bal" ]["balance" ],
164
165
}
165
166
)
166
- if foreign_currency :
167
+ if foreign_currency and account [ "currency_id" ] :
167
168
account .update (
168
169
{"initial_bal_curr" : account ["init_bal" ]["bal_curr" ]}
169
170
)
@@ -177,7 +178,10 @@ def _generate_report_content(self, workbook, report, data, report_data):
177
178
"journal" : journals_data [line ["journal_id" ]]["code" ],
178
179
}
179
180
)
180
- if line ["currency_id" ]:
181
+ line_currency_id = (
182
+ line ["currency_id" ][0 ] if line ["currency_id" ] else False
183
+ )
184
+ if line_currency_id and line_currency_id != company_currency .id :
181
185
line .update (
182
186
{
183
187
"currency_name" : line ["currency_id" ][1 ],
@@ -207,7 +211,11 @@ def _generate_report_content(self, workbook, report, data, report_data):
207
211
"analytic_distribution" : analytic_distribution ,
208
212
}
209
213
)
210
- if foreign_currency :
214
+ if (
215
+ foreign_currency
216
+ and line_currency_id
217
+ and line_currency_id != company_currency .id
218
+ ):
211
219
total_bal_curr += line ["bal_curr" ]
212
220
line .update ({"total_bal_curr" : total_bal_curr })
213
221
self .write_line_from_dict (line , report_data )
@@ -219,7 +227,7 @@ def _generate_report_content(self, workbook, report, data, report_data):
219
227
"final_balance" : account ["fin_bal" ]["balance" ],
220
228
}
221
229
)
222
- if foreign_currency :
230
+ if foreign_currency and account [ "currency_id" ] :
223
231
account .update (
224
232
{
225
233
"final_bal_curr" : account ["fin_bal" ]["bal_curr" ],
@@ -262,7 +270,7 @@ def _generate_report_content(self, workbook, report, data, report_data):
262
270
],
263
271
}
264
272
)
265
- if foreign_currency :
273
+ if foreign_currency and account [ "currency_id" ] :
266
274
group_item .update (
267
275
{
268
276
"initial_bal_curr" : group_item ["init_bal" ]["bal_curr" ],
@@ -278,7 +286,10 @@ def _generate_report_content(self, workbook, report, data, report_data):
278
286
"journal" : journals_data [line ["journal_id" ]]["code" ],
279
287
}
280
288
)
281
- if line ["currency_id" ]:
289
+ line_currency_id = (
290
+ line ["currency_id" ][0 ] if line ["currency_id" ] else False
291
+ )
292
+ if line_currency_id and line_currency_id != company_currency .id :
282
293
line .update (
283
294
{
284
295
"currency_name" : line ["currency_id" ][1 ],
@@ -310,7 +321,11 @@ def _generate_report_content(self, workbook, report, data, report_data):
310
321
"analytic_distribution" : analytic_distribution ,
311
322
}
312
323
)
313
- if foreign_currency :
324
+ if (
325
+ foreign_currency
326
+ and line_currency_id
327
+ and line_currency_id != company_currency .id
328
+ ):
314
329
total_bal_curr += line ["bal_curr" ]
315
330
line .update ({"total_bal_curr" : total_bal_curr })
316
331
self .write_line_from_dict (line , report_data )
0 commit comments