1

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

Mohamed Fouad
  • 476
  • 9
  • 27

1 Answers1

1

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.

Kenly
  • 24,317
  • 7
  • 44
  • 60
  • what is the differance between your answer and if i write super in return like return super(modelname, self)._compute_amount() – Mohamed Fouad Dec 17 '19 at 16:39
  • The compute method has to assign the field on all records of the invoked recordset. The return value should be `None`. And please if you do not mind, What do you expect when returning that value? – Kenly Dec 18 '19 at 09:58