Search code examples
pythoninheritanceormodoo

how to override on odoo methode?


assume there is an model like that

class HolidaysType(models.Model):

_name = "hr.holidays.status"
_description = "Leave Type"

have a method like

api.one
@api.depends('b')
def _compute_amount(self):
    a = b
    m = n
    h = f
    pass

and i need to add an inhertance model as:

class modelname(models.Model):
_inherit = 'hr.holidays.status'

then i need to make c = x+z and a = b+c in _compute_amount method

how can i do that


Solution

  • Override the _compute_amount method and add your code.

    class modelname(models.Model):
        _inherit = 'hr.holidays.status'
    
        @api.one
        @api.depends('b')
        def _compute_amount(self):
            super(modelname, self)._compute_amount()
            c = x+z
            a = b+c
    

    Create a new record to check if the values are correctly computed.

    You can recompute stored functional field values.