mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit hr_department_project for 11.0
This commit is contained in:
2
hr_department_project/__init__.py
Normal file
2
hr_department_project/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import models
|
||||||
24
hr_department_project/__manifest__.py
Normal file
24
hr_department_project/__manifest__.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
'name': 'HR Department Project',
|
||||||
|
'version': '11.0.1.0.0',
|
||||||
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
|
'category': 'Human Resources',
|
||||||
|
'summary': 'Provide default project per Department',
|
||||||
|
'description': """
|
||||||
|
HR Department Project
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Define a 'default project' for every department. This is a bridge module to allow other modules to use this behavior.
|
||||||
|
""",
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'depends': [
|
||||||
|
'project',
|
||||||
|
'hr',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/hr_views.xml',
|
||||||
|
'views/project_views.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
||||||
3
hr_department_project/models/__init__.py
Normal file
3
hr_department_project/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import project
|
||||||
|
from . import hr
|
||||||
22
hr_department_project/models/hr.py
Normal file
22
hr_department_project/models/hr.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from odoo import api, fields, models, _
|
||||||
|
|
||||||
|
|
||||||
|
class Department(models.Model):
|
||||||
|
_inherit = 'hr.department'
|
||||||
|
|
||||||
|
project_ids = fields.One2many('project.project', 'department_id', string='Projects')
|
||||||
|
project_count = fields.Integer(compute='_compute_project_count', string='Project Count')
|
||||||
|
|
||||||
|
def _compute_project_count(self):
|
||||||
|
for department in self:
|
||||||
|
department.project_count = len(department.with_context(active_test=False).project_ids)
|
||||||
|
|
||||||
|
def project_tree_view(self):
|
||||||
|
self.ensure_one()
|
||||||
|
action = self.env.ref('project.open_view_project_all').read()[0]
|
||||||
|
action['domain'] = [('department_id', '=', self.id)]
|
||||||
|
action['context'] = {
|
||||||
|
'default_department_id': self.id,
|
||||||
|
'default_user_id': self.manager_id.id if self.manager_id else 0,
|
||||||
|
}
|
||||||
|
return action
|
||||||
7
hr_department_project/models/project.py
Normal file
7
hr_department_project/models/project.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from odoo import api, fields, models, _
|
||||||
|
|
||||||
|
|
||||||
|
class Project(models.Model):
|
||||||
|
_inherit = 'project.project'
|
||||||
|
|
||||||
|
department_id = fields.Many2one('hr.department', string='Department')
|
||||||
15
hr_department_project/views/hr_views.xml
Normal file
15
hr_department_project/views/hr_views.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="view_department_form_inherited">
|
||||||
|
<field name="name">hr.department.form.inherited</field>
|
||||||
|
<field name="model">hr.department</field>
|
||||||
|
<field name="inherit_id" ref="hr.view_department_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//button[@name='toggle_active']" position="before">
|
||||||
|
<button class="oe_stat_button" name="project_tree_view" type="object" icon="fa-puzzle-piece">
|
||||||
|
<field string="Projects" name="project_count" widget="statinfo"/>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
24
hr_department_project/views/project_views.xml
Normal file
24
hr_department_project/views/project_views.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="edit_project_inherited">
|
||||||
|
<field name="name">project.project.form.inherited</field>
|
||||||
|
<field name="model">project.project</field>
|
||||||
|
<field name="inherit_id" ref="project.edit_project"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='user_id']" position="before">
|
||||||
|
<field name="department_id"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_project_project_filter_inherited">
|
||||||
|
<field name="name">project.project.select.inherited</field>
|
||||||
|
<field name="model">project.project</field>
|
||||||
|
<field name="inherit_id" ref="project.view_project_project_filter"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group/filter[@name='Manager']" position="before">
|
||||||
|
<filter string="Department" name="group_department" context="{'group_by': 'department_id'}"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user