Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
3425 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Tác giả

i tried

@api.one

@api.onchange('resul')

def _onchange_field(self):

if self.resul:

resultado ="10"

self.resul= resultado

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ