Vauxoo / addons-vauxoo

All our modules related to developments that solves generic issues on Odoo, or that solve internal problems on Odoo Core, if something is here, maybe it is solving an issue in your company, try it and report what you see.
http://www.vauxoo.com
193 stars 288 forks source link

[FIX] controller_report_xls: Get Odoo Style #1636

Closed CarmenMiranda closed 8 months ago

CarmenMiranda commented 8 months ago

[FIX] controller_report_xls: Get Odoo Style

When the node had a style like "background-color: #99CCFF; font-weight: bold;" the style that comes after the "; " (with the white-space after the ;) was not being found on the method css2excel. That happened because the get_odoo_style returned the styles like: {'background-color': '#99CCFF', ' font-weight': 'bold'} and the process_css didn't find ' font-weight' in its keys.

Images ![image](https://github.com/Vauxoo/addons-vauxoo/assets/26889951/5c197d32-28a4-4ad9-9ad6-31d59e7ec9d4) ![image](https://github.com/Vauxoo/addons-vauxoo/assets/26889951/3dfb4573-7778-4f5c-b9bb-59f087d9b744)

So now cleaning the values on the get_odoo_style by removing the whitespaces from the beginning and the end of the string, the method will now return {'background-color': '#99CCFF', 'font-weight': 'bold'} and the process_css will find 'font-weight' in its keys.

[FIX] controller_report_xls: Font Height

Before this change there was a traceback when a font-size was added:

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.

CarmenMiranda commented 8 months ago

Hi, @luisg123v Could you review this, please??