Skip to content

[FIX] Selfconsumption distribution coefficient decimal positions

Task: https://somcomunitats.openproject.com/projects/canal-2/work_packages/208/activity

In selfconsumption projects, the distribution coefficient (beta) must have 6 digits after the coma, not 5.

Why (7, 6) and not (1, 6)?

Because from what I understand the first number (total) represents what in Postgres is called precision: "the total count of significant digits in the whole number, that is, the number of digits to both sides of the decimal point".

Odoo uses the (total, decimal) information only to read the data from the DB, the columns in the DB is created as numeric but without any info related to precision or scale. From what I understand Odoo just ignore the total and just use decimal for the rounding while reading.

EDIT:

While testing, I discovered that the rounding actually happens on the write. If you input 0,1234567 it will store 0,123457. In any case... total still not used.

Documentation

https://www.odoo.com/documentation/14.0/developer/reference/addons/orm.html#odoo.fields.Float

https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL

Edited by Enrico Stano

Merge request reports