Use the default digit values to calculate the width for float widget

Closes #14153
This commit is contained in:
Cédric Krier
2025-08-11 18:06:38 +02:00
parent 9a8492d928
commit 67190a2e83
2 changed files with 10 additions and 13 deletions
+8 -8
View File
@@ -2205,14 +2205,14 @@ function eval_pyson(value){
}
},
get width() {
var digits = this.digits;
if (digits && digits.every(d => d !== null)) {
return digits.reduce(function(acc, cur) {
return acc + cur;
});
} else {
return this.attributes.width || 18;
}
let default_ = [16, 2];
let digits = this.digits || [null, null];
return digits.reduce((acc, cur, i) => {
if (cur === null) {
cur = default_[i];
}
return acc + cur;
}, 0);
},
display: function() {
var record = this.record;
@@ -13,11 +13,8 @@ class Float(Integer):
@property
def width(self):
digits = self.digits
if digits and all(d is not None for d in digits):
return sum(digits)
else:
return self.attrs.get('width', 18)
digits = self.digits or [None, None]
return sum(v if v is not None else d for v, d in zip(digits, [16, 2]))
def display(self):
self.entry.digits = self.digits