Skip to content

Commit

Permalink
[MIG] okr_module: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jok-adhoc committed Feb 1, 2024
1 parent 828d113 commit b213904
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion okr_module/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import models
from . import models
6 changes: 3 additions & 3 deletions okr_module/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'name': 'OKR Module',
'version': '16.0.1.0.0',
'version': "17.0.1.0.0",
'category': 'Base',
'sequence': 14,
'summary': '',
Expand All @@ -9,7 +9,7 @@
'license': 'AGPL-3',
'images': [
],
'depends': [
'depends': ['contacts'
],
'data': ['security/ir.model.access.csv',
'views/okr_base.xml',
Expand All @@ -20,4 +20,4 @@
'installable': True,
'auto_install': False,
'application': True,
}
}
2 changes: 1 addition & 1 deletion okr_module/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import okr_base
from . import okr_base
19 changes: 12 additions & 7 deletions okr_module/models/okr_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ class OkrBase(models.Model):
_description = 'OKR BASE'
_name = "okr.base"

name = fields.Char()
name = fields.Char(required=True)
description = fields.Char()
user_id = fields.Many2one('res.users')
completed_percentage = fields.Float(compute='_compute_completed_percentage')
type = fields.Selection(selection=[('commitment', 'commitment'),('inspirational', 'inspirational')], required=True)
kr_line_ids = fields.One2many('okr.base.line', 'okr_base_id')

def _compute_completed_percentage(self):
for kr in self:
if kr.kr_line_ids:
cum = 0
cant = 0
w_cum = 0
sum_weigh = 0
for krl in kr.kr_line_ids:
cum += krl.completed_percentage
cant += 1
kr.completed_percentage = cum/cant
w_cum += krl.completed_percentage*krl.weight
sum_weigh += krl.weight
kr.completed_percentage = w_cum/sum_weigh
else:
kr.completed_percentage = 0

Expand All @@ -27,8 +30,11 @@ class OkrBaseLine(models.Model):
_name = "okr.base.line"

name = fields.Char()
description = fields.Char()
user_id = fields.Many2one('res.users')
okr_base_id = fields.Many2one(comodel_name='okr.base', required=True)
actual_value = fields.Float()
weight = fields.Float()
target = fields.Float()
completed_percentage = fields.Float(compute='_compute_completed_percentage_line')

Expand All @@ -39,4 +45,3 @@ def _compute_completed_percentage_line(self):
kr.completed_percentage = (kr.actual_value/kr.target)
else:
kr.completed_percentage = 1

14 changes: 11 additions & 3 deletions okr_module/views/okr_base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@
<field name="model">okr.base</field>
<field name="arch" type="xml">
<form create="1">
<field name="name"/>
<field name="completed_percentage"/>
<group>
<group>
<field name="name"/>
<field name="type"/>
<field name="user_id"/>
<field name="completed_percentage"/>
</group>
</group>
<field name="kr_line_ids">
<tree create="1">
<field name="name"/>
<field name="actual_value"/>
<field name="target"/>
<field name="completed_percentage"/>
<field name="weight"/>
<field name="user_id"/>
</tree>
</field>
</form>
Expand All @@ -40,4 +48,4 @@
</field>
</record>

</odoo>
</odoo>

0 comments on commit b213904

Please sign in to comment.