# Function fields digits

**URL:** https://discuss.tryton.org/t/function-fields-digits/6856
**Category:** Developer
**Created:** [January 8, 2024, 4:10pm UTC](https://discuss.tryton.org/t/function-fields-digits/6856 "2024-01-08T16:10:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [January 8, 2024, 4:10pm UTC](https://discuss.tryton.org/t/function-fields-digits/6856/1 "2024-01-08T16:10:57Z")

</div>

Hi,

When I add “digits=‘field\_unit’” to a Numeric field in a Function field, the system ask to save the record when I read it and try to read the next one.  
Is there something special with the formatting of a field in a Function field ?

KR,  
Laurent

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 8, 2024, 4:24pm UTC](https://discuss.tryton.org/t/function-fields-digits/6856/2 "2024-01-08T16:24:01Z")

</div>

It is probably because the existing value is not properly rounded.

---

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [January 8, 2024, 4:51pm UTC](https://discuss.tryton.org/t/function-fields-digits/6856/3 "2024-01-08T16:51:28Z")

</div>

Exact it’s the cause.  
How can I convert Decimal(1.11111111…) to Decimal(1.11) without using a string format like {0:0.2f}".format() ?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 8, 2024, 4:58pm UTC](https://discuss.tryton.org/t/function-fields-digits/6856/4 "2024-01-08T16:58:34Z")

</div>

```auto
>>> round(Decimal('1.1111111111'), 2)
Decimal('1.11')

```

---

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [January 8, 2024, 5:18pm UTC](https://discuss.tryton.org/t/function-fields-digits/6856/5 "2024-01-08T17:18:11Z")

</div>

shame on me 🙂 Tks Cedric
