Search code examples
pythonodoo

How to get field's default value from other field in odoo?


I my module I have an entity "Bill" with two float fields "total" and "remaining" I want "remaining" to take its default value from "total". How can I do that? I have tried these with but when I try to create a new "Bill" it shows an error "TypeError: float() argument must be a string or a number, not 'Float'"

total = fields.Float(string='Total', digits=(10, 2)) remaining = fields.Float(string='Remaining', digits=(10, 2) default=total)


Solution

  • Make them Related field,

    remaining = fields.Float(related=total, string='Remaining')