Skip to content

Commit

Permalink
[FIX] controller_report_xls: Font Height
Browse files Browse the repository at this point in the history
Before this change there was a traceback when a `font-size` was added:
```python
File "/usr/local/lib/python3.8/dist-packages/xlwt/BIFFRecords.py", line 725, in __init__
    self._rec_data = pack('<5H4B%ds' % uname_len, height, options, colour_index, weight, escapement,
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/odoo/instance/odoo/odoo/http.py", line 654, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo/instance/odoo/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
struct.error: required argument is not an integer
```

That happened because the `height` expected for the fonts is an integer
value and the `get_font_height` was returning `float` values, for
example: "125.0", now we are rounding the new size to 0 decimals to
return the closest integer for that size.
  • Loading branch information
CarmenMiranda authored and hugho-ad committed Jan 24, 2024
1 parent 5b124ec commit b8fcca0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controller_report_xls/reports/xfstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def get_font_height(height):
factor = 1.5
elif height == "XX-LARGE":
factor = 2
new_size = float(size * factor * 20)
return new_size
# NOTE: Rounding without decimals because the expected `height` needs to be an `integer` value
return round(size * factor * 20)


def get_horizontal_align(halign, align):
Expand Down

0 comments on commit b8fcca0

Please sign in to comment.