Odoo Help


save custom field in account form.

on 6/28/16, 3:20 PM 511 views

i made a new field in account form and it work well i calculated on it as well but when i save it, my new field was reset to 0.

I cant save the form with my field information and i dont know why?

from openerp import models, fields, api, exceptions

class ColombianTaxes(models.Model):

""" Model to create and manipulate personal taxes"""

_description= "Model to create own taxes"

_name = 'account.invoice'

_inherit = 'account.invoice'

# Define rfuente as new tax.

rfuente = fields.Monetary('Retencion en la fuente:',store="True" , compute = "rfuente_pc")

# Calculate rfuente and total amount

@api.onchange('amount_untaxed', 'amount_total')

def rfuente_pc(self):

self.rfuente = self.amount_untaxed * 0.025

self.amount_total = self.amount_total + self.rfuente

Nikunj Antala
On 6/29/16, 12:51 AM

 @api.onchange will call in change of simple form field. But, when you want to use computed field (field.function) then you need to use @api.depends decorator.


compute_field = fields.Text(
    string="Compute Field", store=True,
@api.depends('employee_id') def _get_compute_field(self): if self.employee_id.department_id: self.compute_field = self.employee_id.department_id.name

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/28/16, 3:20 PM
Seen: 511 times
Last updated: 7/11/16, 9:22 AM