Obtain number of records of a module

0

Good morning gentlemen, I have a problem since I am very new in odoo yet.

I am trying to create a kanban view in which the information of the department, current date, and number of incidents of that department are shown, my problem is that I can not obtain the number of incidents of a department, I clarify that I use the module that comes with odoo of leave management, in which you register, missing delays and thus, payroll things I suppose, and this I am trying to do in a class apart from the one that brings the module to not modify the base code that it has. I append the code I did, it tells me that you can not access the tuple, I suppose because if you are not accessing the correct class, thank you.

class count_leaves (models.Model):

_name = "hr.holidays.department_id"

department = fields.Many2one('hr.department')

department_id = fields.Integer(compute='_action_count')

count_leaves = fields.Integer()

@api.multi
def _action_count(self):
    id_department = self.department.id
    self.department_id=id_department
    holidays = self.env['hr.holidays'].search([
        ('state','in',['validate','validate1'])
        ('department_id','=',id_department)])
    ##Opcion 1
    #self.count_leaves = len(holidays)
    ##Opcion 2
    cont=0
    for get_count in holidays:
        cont +=1
    self.count_leaves = cont
    
asked by Ismael 18.05.2018 в 01:07
source

0 answers