Files
app-odoo/app_hr_department_chart/models/hr_department.py
2019-11-12 18:56:15 +08:00

24 lines
727 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
from odoo import api, fields, models, tools, _
class Department(models.Model):
# 目录图片,可显示小图标,
_name = "hr.department"
_inherit = ['hr.department', 'image.mixin']
# 目录图片可显示小图标odoo13 在 mixin 中处理了
child_all_count = fields.Integer(
'Indirect Surbordinates Count',
compute='_compute_child_all_count', store=False)
manager_name = fields.Char(related="manager_id.name", store=True)
@api.depends('child_ids.child_all_count')
def _compute_child_all_count(self):
for rec in self:
rec.child_all_count = len(rec.child_ids) + sum(child.child_all_count for child in rec.child_ids)