This question has been flagged
3 Replies
3045 Views

from openerp import models, fields, api, exceptions

import re

class ColombianTaxes(models.Model):

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

     _description= "Model to create own taxes"

    _name = 'account.invoice'

    _inherit = 'account.invoice'

# This is a colombian tax named Retenciòn en la fuente

     resul= fields.Integer(string='resultado', default = 10 ,store=True, compute="_resul_pc")

    @api.onchange('resul')

    @api.depends('resul')

    def _resul_pc(self):

        self.resul = 100

Avatar
Discard
Author

the field on the view just dont take the value is still 0, i tried with and without @api.onchange @api.one, @api.depends('resul') without any @api it just dont change, and i dont have any error by odoo.

Author

i tried

@api.one

@api.onchange('resul')

def _onchange_field(self):

if self.resul:

resultado ="10"

self.resul= resultado

Best Answer

Hi,

Put your function before the field defination.

and use below code:

@api.one

def _onchange_field(self):
     self.resul = 100 # or here you can do your calculation.


then update the module and refresh the view of the form on save you will get the 100 in resul field.

Avatar
Discard