Odoo Help

0

numeric value on an inherit field. computed fields.

By
JORGE TORRES
on 6/23/16, 5:39 PM 277 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

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.

JORGE TORRES
on 6/23/16, 5:44 PM

i tried

@api.one

@api.onchange('resul')

def _onchange_field(self):

if self.resul:

resultado ="10"

self.resul= resultado

JORGE TORRES
on 6/23/16, 5:45 PM
0
Krupesh Laiya
On 6/24/16, 1:51 AM

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.

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.

Register

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)

Stats

Asked: 6/23/16, 5:39 PM
Seen: 277 times
Last updated: 6/24/16, 1:51 AM