Skip to content

Commit

Permalink
[ADD] okr: new module
Browse files Browse the repository at this point in the history
  • Loading branch information
ced-adhoc committed Feb 23, 2024
1 parent acded81 commit 1b6716b
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 0 deletions.
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
19 changes: 19 additions & 0 deletions okr/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
'name': 'okr',
'version' : '16.0.1.0',
'author' : 'ced',
'license' : 'AGPL-3',
'depends': ['base', 'hr'],
'data': [
'security/ir.model.access.csv',
'views/okr_objective_views.xml',
'views/okr_key_result_views.xml',
'views/okr_menu.xml',
],
'demo': [],
'application': True,
'installable': True,
'auto_install': False


}
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
30 changes: 30 additions & 0 deletions okr/models/okr_key_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import models, fields, api

class OkrKeyResult(models.Model):
_name = 'okr.key_result'
_description = 'OKR Key Result'

name = fields.Char(required=True)
description = fields.Text(required=True)
department_id = fields.Many2one('hr.department')
user_id = fields.Many2one('res.users', string= 'Responsible')
objective_id = fields.Many2one('okr.objective')
weight = fields.Integer()
target = fields.Integer()
result = fields.Integer()
progress = fields.Float(compute = 'compute_progress', store=True, default=0)
# state?
# interdependencias
# plan de acción
# comentarios

@api.depends('result','target')
def _compute_progress(self):
for rec in self:
if rec.target !=0:
rec.progress = (rec.result)/(rec.target)*100
else:
rec.progress = 0.0



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

class OkrObjective(models.Model):
_name = 'okr.objective'
_description = 'OKR Objectives'

name = fields.Char(required=True)
description = fields.Text(required=True)
user_id = fields.Many2one('res.users', string= 'Responsible')
progress = fields.Integer(default = 0)
type = fields.Selection([('commitment', 'Commitment'),('inspirational', 'Inspirational')])
quarter = fields.Selection([('q1', 'Q1'),('q2', 'Q2'),('q3', 'Q3'),('q4', 'Q4')])
department_id = fields.Many2one('hr.department', required=True)
key_result_ids = fields.One2many('okr.key_result', 'objective_id')
notes = fields.Text()
# state
#compute = 'compute_progress'






3 changes: 3 additions & 0 deletions okr/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
okr.access_okr_objective,access_okr_objective,okr.model_okr_objective,base.group_user,1,1,1,0
okr.access_okr_key_result,access_okr_key_result,okr.model_okr_key_result,base.group_user,1,1,1,0
49 changes: 49 additions & 0 deletions okr/views/okr_key_result_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<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"/>
<field name="department_id"/>
<field name="user_id"/>
<field name="objective_id"/>
<field name="progress"/>
<field name="weight"/>
<field name="target"/>
<field name="result"/>
</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>
<sheet>
<group>
<field name="name"/>
<field name="description"/>
<field name="department_id"/>
<field name="user_id"/>
<field name="objective_id"/>
<field name="progress"/>
<field name="weight"/>
<field name="target"/>
<field name="result"/>
</group>
</sheet>
</form>
</field>
</record>

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

</odoo>

12 changes: 12 additions & 0 deletions okr/views/okr_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<menuitem id="okr_menu" name="OKR Management"/>
<!-- groups="group_okr_objective" -->
<menuitem id="okr_objective_menu" name="OKR Objectives" action="okr_objective_action" parent="okr_menu"/>
<!-- groups="group_okr_key_result" -->
<!-- web_icon="fa fa-info,#f1c40f,#34495e" -->
<menuitem id="okr_key_result_menu" name="OKR Key Results" action="okr_key_result_action" parent = "okr_menu"/>

</odoo>

54 changes: 54 additions & 0 deletions okr/views/okr_objective_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<odoo>
<record id="view_okr_objective_tree" model="ir.ui.view">
<field name="name">okr.objective.tree</field>
<field name="model">okr.objective</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="description"/>
<field name="department_id"/>
<field name="user_id"/>
<field name="type"/>
<field name="progress"/>
<field name="quarter"/>
</tree>
</field>
</record>

<record id="view_okr_objective_form" model="ir.ui.view">
<field name="name">okr.objective.form</field>
<field name="model">okr.objective</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="description"/>
<field name="department_id"/>
<field name="user_id"/>
<field name="type"/>
<field name="progress"/>
<field name="quarter"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="view_okr_objective_search" model="ir.ui.view">
<field name="name">okr.objective.search</field>
<field name="model">okr.objective</field>
<field name="arch" type="xml">
<search>
<field name="name" />
</search>
</field>
</record>

<record id="okr_objective_action" model="ir.actions.act_window">
<field name="name">OKR Objective</field>
<field name="res_model">okr.objective</field>
<field name='view_mode'>tree,form</field>
</record>

</odoo>

0 comments on commit 1b6716b

Please sign in to comment.