In Odoo/OpenERP 7, I have a nullable numeric column called balance
'balance': fields.float(string='Balance',digits=(20,2))
I am trying to use Python code to update None
into the field
self.write(cr, uid, [1], { 'balance':None })
but, rather frustratingly, Python treats None the same as 0 so I end up with 0 in the DB instead of the expected Null.
Any pointers on how I can use the write command to store a null value?
You can't: the Odoo ORM does not support null numeric values.
If you really need to distinguish an "empty" value from a zero value, you need a workaround: either use a string field (simpler, but needs additional checks to allow only number and it's harder to perform calculations) or use a second boolean field to mark empty values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With