Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] okr: add module for okr management #152

Open
wants to merge 3 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions okr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions okr/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
'name': 'OKR',
'version': "17.0.1.0.0",
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'depends': [
'hr',
],
'data': [
'views/okr_objective_views.xml',
'views/okr_key_result_views.xml',
'security/security.xml',
'security/ir.model.access.csv',
],
'demo': [
'demo/okr_objective_demo.xml',
],
'installable': True,
}
9 changes: 9 additions & 0 deletions okr/demo/okr.objective.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id,name,department_id,description,from_date,to_date,type,user_id
okr_objective_q1_sustentabilidad_crecer,Crecer,Management / Administration,Lograr escalabilidad en los procesos masivos,2024-01-01,2024-02-29,Commitment,Mitchell Admin
okr_objective_q1_sustentabilidad_admin,Sustentabilidad,Management / Administration,Ser robustos en los procesos actuales en búsqueda de la seguridad de los mismos,2024-01-01,2024-02-29,Commitment,Mitchell Admin
okr_objective_q1_sustentabilidad_valor,Agregar valor al cliente,Management / Research & Development / R&D USA,Agregar valor a traves de mayor agilidad y mejor comunicacion,2024-01-01,2024-02-29,Commitment,Mitchell Admin
okr_objective_q1_sustentabilidad_rd,Sustentabilidad,Management / Research & Development / R&D USA,"Actualizar clientes a full, lanzar la 17 y trabajar en cultura de seguridad",2024-01-01,2024-02-29,Commitment,Mitchell Admin
okr_objective_q1_valor,Agregar valor al cliente,,Agregar valor a traves de mayor agilidad y mejor comunicacion,2024-01-01,2024-02-29,Commitment,Mitchell Admin
okr_objective_q1_crecer,Crecer,,"Crecer internacionalmente, consolidando Uruguay",2024-01-01,2024-02-29,Commitment,Mitchell Admin
okr_objective_year_crecer,Crecer,,Crecer en toda la organizacion poniendo foco en lo internacional,2024-01-01,eval(time.strftime('%Y-12-31')),Inspirational,Mitchell Admin
okr_objective_year_valor,Valor al cliente,,Aportar mas valor al cliente de manera cada vez mas tecnologica y sistematica,2024-01-01,eval(time.strftime('%Y-12-31')),Commitment,Mitchell Admin
79 changes: 79 additions & 0 deletions okr/demo/okr_objective_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<odoo>

<record id="okr_objective_year_crecer" model="okr.objective">
<field name="name">Crecer</field>
<field name="description">Crecer en toda la organizacion poniendo foco en lo internacional</field>
<field name="type">commitment</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="time.strftime('%Y-12-31')"/>
</record>

<record id="okr_objective_year_valor" model="okr.objective">
<field name="name">Valor al Cliente</field>
<field name="description">Aportar mas valor al cliente de manera cada vez mas tecnologica y sistematica</field>
<field name="type">inspirational</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="time.strftime('%Y-12-31')"/>
</record>

<record id="okr_objective_q1_crecer" model="okr.objective">
<field name="name">Crecer internacionalmente, consolidando Uruguay</field>
<field name="description">Crecer en toda la organizacion poniendo foco en lo internacional</field>
<field name="type">commitment</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="(DateTime.today() + relativedelta(months=3, days=-1, day=1)).strftime('%Y-%m-%d %H:%M:00')"/>
</record>

<record id="okr_objective_q1_valor" model="okr.objective">
<field name="name">Agregar valor al cliente,,Agregar valor a traves de mayor agilidad y mejor comunicacion</field>
<field name="description">Aportar mas valor al cliente de manera cada vez mas tecnologica y sistematica</field>
<field name="type">inspirational</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="(DateTime.today() + relativedelta(months=3, days=-1, day=1)).strftime('%Y-%m-%d %H:%M:00')"/>
</record>

<record id="okr_objective_q1_crecer_admin" model="okr.objective">
<field name="name">Crecer</field>
<field name="description">Lograr escalabilidad en los procesos masivos</field>
<field name="type">commitment</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="(DateTime.today() + relativedelta(months=3, days=-1, day=1)).strftime('%Y-%m-%d %H:%M:00')"/>
<field name="department_id" ref="hr.dep_administration"/>
</record>

<record id="okr_objective_q1_sustentabilidad_admin" model="okr.objective">
<field name="name">Sustentabilidad</field>
<field name="description">Ser robustos en los procesos actuales en búsqueda de la seguridad de los mismos</field>
<field name="type">inspirational</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="(DateTime.today() + relativedelta(months=3, days=-1, day=1)).strftime('%Y-%m-%d %H:%M:00')"/>
<field name="department_id" ref="hr.dep_administration"/>
</record>

<record id="okr_objective_q1_valor_rd" model="okr.objective">
<field name="name">Agregar valor al cliente</field>
<field name="description">Agregar valor a traves de mayor agilidad y mejor comunicacion</field>
<field name="type">commitment</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="(DateTime.today() + relativedelta(months=3, days=-1, day=1)).strftime('%Y-%m-%d %H:%M:00')"/>
<field name="department_id" ref="hr.dep_rd_be"/>
</record>

<record id="okr_objective_q1_sustentabilidad_rd" model="okr.objective">
<field name="name">Sustentabilidad</field>
<field name="description">Actualizar clientes a full, lanzar la 17 y trabajar en cultura de seguridad</field>
<field name="type">inspirational</field>
<field name="user_id" ref="base.user_admin"/>
<field name="from_date" eval="time.strftime('%Y-1-1')"/>
<field name="to_date" eval="(DateTime.today() + relativedelta(months=3, days=-1, day=1)).strftime('%Y-%m-%d %H:%M:00')"/>
<field name="department_id" ref="hr.dep_rd_be"/>
</record>

</odoo>
2 changes: 2 additions & 0 deletions okr/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import okr_key_result
from . import okr_objective
23 changes: 23 additions & 0 deletions okr/models/okr_key_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from odoo import models, fields, api


class OkrKeyResult(models.Model):
_name = 'okr.key_result'
_description = 'OKR Key Result'
_inherit = ['mail.thread', 'mail.activity.mixin']

name = fields.Char(required=True)
description = fields.Html()
objective_id = fields.Many2one('okr.objective', required=True, ondelete='cascade')
department_ids = fields.Many2many('hr.department', string='Interdependencies')
user_id = fields.Many2one('res.users', string='Responsible', required=True)
weight = fields.Integer(required=True)
target = fields.Integer(required=True)
result = fields.Integer()
progress = fields.Integer(compute='_compute_progress', store=True)
company_id = fields.Many2one(related='objective_id.company_id', store=True)

@api.depends('result', 'target')
def _compute_progress(self):
for rec in self:
rec.progress = rec.result / rec.target * 100 if rec.target else 100
30 changes: 30 additions & 0 deletions okr/models/okr_objective.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import models, fields, api


class OkrObjective(models.Model):
_name = 'okr.objective'
_description = 'OKR Objectives'
_inherit = ['mail.thread', 'mail.activity.mixin']
_check_company_auto = True
_check_company_domain = models.check_company_domain_parent_of
# _parent_store = True
_order = 'from_date, department_id, to_date, name'

name = fields.Char(required=True)
description = fields.Char(required=True)
notes = fields.Html()
from_date = fields.Date(required=True)
to_date = fields.Date(required=True)
# parent_path = fields.Char(index=True, unaccent=False)
# parent_id = fields.Many2one('okr.objective', index=True, ondelete='cascade', check_company=True)
department_id = fields.Many2one('hr.department',)
user_id = fields.Many2one('res.users', string='Responsible', required=True)
key_result_ids = fields.One2many('okr.key_result', 'objective_id', string='Key Results')
type = fields.Selection([('commitment', 'Commitment'), ('inspirational', 'Inspirational')], required=True)
progress = fields.Integer(compute='_compute_progress', store=True)
company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company)

@api.depends('key_result_ids.progress', 'key_result_ids.weight')
def _compute_progress(self):
for rec in self:
rec.progress = sum(x.progress * x.weight/100 for x in rec.key_result_ids)
4 changes: 4 additions & 0 deletions okr/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_okr_key_result_user,access_okr_key_result_user,model_okr_key_result,group_okr_user,1,1,1,1
access_okr_objective_user,access_okr_objective_user,model_okr_objective,group_okr_user,1,1,0,0
access_okr_objective_manager,access_okr_objective_manager,model_okr_objective,group_okr_manager,1,1,1,1
75 changes: 75 additions & 0 deletions okr/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<odoo>
<data noupdate="0">


<record model="ir.module.category" id="module_category_okr">
<field name="name">OKR</field>
</record>
<record id="group_okr_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_okr"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_okr_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_category_okr"/>
<field name="implied_ids" eval="[(4, ref('group_okr_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>

</data>
<data noupdate="1">

<record id="okr_objective_comp_rule" model="ir.rule">
<field name="name">OKR objective company rule</field>
<field name="model_id" ref="model_okr_objective"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>

<record id="okr_key_result_comp_rule" model="ir.rule">
<field name="name">OKR Key Result company rule</field>
<field name="model_id" ref="model_okr_key_result"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>

<record id="okr_key_result_user_rule_by_objective" model="ir.rule">
<field name="name">OKR Key Result user rule by objective</field>
<field name="model_id" ref="model_okr_key_result"/>
<field name="groups" eval="[(4, ref('okr.group_okr_user'))]"/>
<field name="domain_force">[('objective_id.user_id', '=', user.id)]</field>
</record>

<record id="okr_key_result_user_rule" model="ir.rule">
<field name="name">OKR Key Result user rule</field>
<field name="model_id" ref="model_okr_key_result"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('okr.group_okr_user'))]"/>
<field name="perm_unlink" eval="False"/>
<field name="perm_create" eval="False"/>
</record>

<record id="okr_key_result_manager_rule" model="ir.rule">
<field name="name">OKR Key Result manager rule</field>
<field name="model_id" ref="model_okr_key_result"/>
<field name="groups" eval="[(4, ref('okr.group_okr_manager'))]"/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>

<record id="okr_objective_user_rule" model="ir.rule">
<field name="name">OKR Objective user rule</field>
<field name="model_id" ref="model_okr_objective"/>
<field name="groups" eval="[(4, ref('okr.group_okr_user'))]"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
<field name="perm_unlink" eval="False"/>
<field name="perm_create" eval="False"/>
</record>

<record id="okr_objective_manager_rule" model="ir.rule">
<field name="name">OKR Objective manager rule</field>
<field name="model_id" ref="model_okr_objective"/>
<field name="groups" eval="[(4, ref('okr.group_okr_manager'))]"/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>

</data>
</odoo>
87 changes: 87 additions & 0 deletions okr/views/okr_key_result_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<odoo>

<record id="view_okr_key_result_tree" model="ir.ui.view">
<field name="name">okr.key_result.tree</field>
<field name="model">okr.key_result</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="description" optional="hide"/>
<field name="user_id" optional="show"/>
<field name="department_ids" widget="many2many_tags" optional="hide"/>
<field name="weight"/>
<field name="target"/>
<field name="result"/>
<field name="progress"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</record>

<record id="view_okr_key_result_form" model="ir.ui.view">
<field name="name">okr.key_result.form</field>
<field name="model">okr.key_result</field>
<field name="arch" type="xml">
<form>
<group>
<field name="name"/>
<field name="description"/>
</group>
<group>
<group>
<field name="user_id"/>
<field name="department_ids" widget="many2many_tags"/>
<field name="weight"/>
</group>
<group>
<field name="target"/>
<field name="result"/>
<field name="progress"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
<div class="oe_chatter">
<field name="message_follower_ids" groups="base.group_user"/>
<field name="activity_ids"/>
<field name="message_ids"/>
</div>
</form>
</field>
</record>

<record id="view_okr_key_result_search" model="ir.ui.view">
<field name="name">okr.key_result.search</field>
<field name="model">okr.key_result</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="description"/>
<field name="user_id"/>
<field name="department_ids"/>
<field name="weight"/>
<field name="target"/>
<field name="result"/>
<field name="progress"/>
<field name="company_id" groups="base.group_multi_company"/>
<separator/>
<filter invisible="1" string="Late Activities" name="activities_overdue"
domain="[('my_activity_date_deadline', '&lt;', context_today().strftime('%Y-%m-%d'))]"
help="Show all records which has next action date is before today"/>
<filter invisible="1" string="Today Activities" name="activities_today"
domain="[('my_activity_date_deadline', '=', context_today().strftime('%Y-%m-%d'))]"/>
<filter invisible="1" string="Future Activities" name="activities_upcoming_all"
domain="[('my_activity_date_deadline', '&gt;', context_today().strftime('%Y-%m-%d'))]"/>
</search>
</field>
</record>

<record id="action_okr_key_result" model="ir.actions.act_window">
<field name="name">OKR Key Results</field>
<field name="res_model">okr.key_result</field>
<field name="target">current</field>
<field name='view_mode'>tree,form</field>
</record>

<menuitem id="menu_okr_key_result" sequence="20" name="Key Results" action="action_okr_key_result" parent="menu_okr"/>

</odoo>
Loading