Reputation: 9670
I would like to reset all the fields of one form with one instruction in Odoo v8. Is that possible? If not, I will have to reset each field one by one and that is not very clean code
Upvotes: 0
Views: 1359
Reputation: 56
You can assign to all fields (except MAGIC_COLUMNS) the values of the empty model.
from openerp import models
# ... other code
@api.multi
def reset(self):
empty_obj = self.env[self._name]
for key, value in self._fields.iteritems():
if value.name not in models.MAGIC_COLUMNS:
setattr(self, key, getattr(empty_obj, key))
Upvotes: 4