|
5 | 5 | import base64
|
6 | 6 | import io
|
7 | 7 | from datetime import timedelta
|
| 8 | +from xml.sax.saxutils import escape |
8 | 9 |
|
9 | 10 | from reportlab.lib import colors
|
10 | 11 | from reportlab.lib.enums import TA_RIGHT
|
@@ -308,8 +309,12 @@ def get_initial_balance_data_report_giornale(self):
|
308 | 309 | "",
|
309 | 310 | "",
|
310 | 311 | Paragraph(_("Initial Balance"), style_name),
|
311 |
| - Paragraph(formatLang(self.env, self.progressive_debit2), style_number), |
312 |
| - Paragraph(formatLang(self.env, self.progressive_credit), style_number), |
| 312 | + Paragraph( |
| 313 | + escape(formatLang(self.env, self.progressive_debit2)), style_number |
| 314 | + ), |
| 315 | + Paragraph( |
| 316 | + escape(formatLang(self.env, self.progressive_credit)), style_number |
| 317 | + ), |
313 | 318 | ]
|
314 | 319 | ]
|
315 | 320 | return initial_balance_data
|
@@ -338,27 +343,28 @@ def get_grupped_final_tables_report_giornale(
|
338 | 343 | )
|
339 | 344 | if not account_name:
|
340 | 345 | continue
|
341 |
| - # evitiamo che i caratteri < o > vengano interpretato come tag html |
342 |
| - # dalla libreria reportlab |
343 |
| - account_name = account_name.replace("<", "<").replace(">", ">") |
344 | 346 |
|
345 | 347 | start_row += 1
|
346 |
| - row = Paragraph(str(start_row), style_name) |
347 |
| - date = Paragraph(format_date(self.env, line["date"]), style_name) |
348 |
| - move = Paragraph(line["move_name"], style_name) |
349 |
| - account = Paragraph(account_name, style_name) |
350 |
| - name = Paragraph(line["name"], style_name) |
| 348 | + row = Paragraph(escape(str(start_row)), style_name) |
| 349 | + date = Paragraph(escape(format_date(self.env, line["date"])), style_name) |
| 350 | + move = Paragraph(escape(line["move_name"]), style_name) |
| 351 | + account = Paragraph(escape(account_name), style_name) |
| 352 | + name = Paragraph(escape(line["name"]), style_name) |
351 | 353 | # dato che nel SQL ho la somma dei crediti e debiti potrei avere
|
352 | 354 | # che un conto ha sia debito che credito
|
353 | 355 | lines_data = []
|
354 | 356 | if line["debit"] > 0:
|
355 |
| - debit = Paragraph(formatLang(self.env, line["debit"]), style_number) |
356 |
| - credit = Paragraph(formatLang(self.env, 0), style_number) |
| 357 | + debit = Paragraph( |
| 358 | + escape(formatLang(self.env, line["debit"])), style_number |
| 359 | + ) |
| 360 | + credit = Paragraph(escape(formatLang(self.env, 0)), style_number) |
357 | 361 | list_balance.append((line["debit"], 0))
|
358 | 362 | lines_data.append([[row, date, move, account, name, debit, credit]])
|
359 | 363 | if line["credit"] > 0:
|
360 |
| - debit = Paragraph(formatLang(self.env, 0), style_number) |
361 |
| - credit = Paragraph(formatLang(self.env, line["credit"]), style_number) |
| 364 | + debit = Paragraph(escape(formatLang(self.env, 0)), style_number) |
| 365 | + credit = Paragraph( |
| 366 | + escape(formatLang(self.env, line["credit"])), style_number |
| 367 | + ) |
362 | 368 | list_balance.append((0, line["credit"]))
|
363 | 369 | lines_data.append([[row, date, move, account, name, debit, credit]])
|
364 | 370 | for line_data in lines_data:
|
@@ -394,25 +400,24 @@ def get_final_tables_report_giornale(
|
394 | 400 |
|
395 | 401 | for line in self.env["account.move.line"].browse(move_line_ids):
|
396 | 402 | start_row += 1
|
397 |
| - row = Paragraph(str(start_row), style_name) |
398 |
| - date = Paragraph(format_date(self.env, line.date), style_name) |
399 |
| - ref = Paragraph(str(line.ref or ""), style_name) |
| 403 | + row = Paragraph(escape(str(start_row)), style_name) |
| 404 | + date = Paragraph(escape(format_date(self.env, line.date)), style_name) |
| 405 | + ref = Paragraph(escape(str(line.ref or "")), style_name) |
400 | 406 | move_name = line.move_id.name or ""
|
401 |
| - move = Paragraph(move_name, style_name) |
| 407 | + move = Paragraph(escape(move_name), style_name) |
402 | 408 | account_name = self._get_account_name_reportlab(line)
|
403 | 409 | # evitiamo che i caratteri < o > vengano interpretato come tag html
|
404 | 410 | # dalla libreria reportlab
|
405 |
| - account_name = account_name.replace("<", "<").replace(">", ">") |
406 |
| - account = Paragraph(account_name, style_name) |
| 411 | + account = Paragraph(escape(account_name), style_name) |
407 | 412 | if line.account_id.account_type in [
|
408 | 413 | "asset_receivable",
|
409 | 414 | "liability_payable",
|
410 | 415 | ]:
|
411 |
| - name = Paragraph(str(line.partner_id.name or ""), style_name) |
| 416 | + name = Paragraph(escape(str(line.partner_id.name or "")), style_name) |
412 | 417 | else:
|
413 |
| - name = Paragraph(str(line.name or ""), style_name) |
414 |
| - debit = Paragraph(formatLang(self.env, line.debit), style_number) |
415 |
| - credit = Paragraph(formatLang(self.env, line.credit), style_number) |
| 418 | + name = Paragraph(escape(str(line.name or "")), style_name) |
| 419 | + debit = Paragraph(escape(formatLang(self.env, line.debit)), style_number) |
| 420 | + credit = Paragraph(escape(formatLang(self.env, line.credit)), style_number) |
416 | 421 | list_balance.append((line.debit, line.credit))
|
417 | 422 | line_data = [[row, date, ref, move, account, name, debit, credit]]
|
418 | 423 | if previous_move_name != move_name:
|
@@ -441,8 +446,8 @@ def get_balance_data_report_giornale(self, tot_debit, tot_credit, final=False):
|
441 | 446 | "",
|
442 | 447 | "",
|
443 | 448 | name,
|
444 |
| - Paragraph(formatLang(self.env, tot_debit), style_number), |
445 |
| - Paragraph(formatLang(self.env, tot_credit), style_number), |
| 449 | + Paragraph(escape(formatLang(self.env, tot_debit)), style_number), |
| 450 | + Paragraph(escape(formatLang(self.env, tot_credit)), style_number), |
446 | 451 | ]
|
447 | 452 | ]
|
448 | 453 | return balance_data
|
|
0 commit comments