From 6df3facba4e2106e85fac320789baaf902aad0eb Mon Sep 17 00:00:00 2001 From: jok-adhoc Date: Thu, 1 Feb 2024 11:13:45 -0300 Subject: [PATCH] [MIG] okr_module: Migration to 17.0 --- okr_module/__init__.py | 2 +- okr_module/__manifest__.py | 6 +++--- okr_module/models/__init__.py | 2 +- okr_module/models/okr_base.py | 22 +++++++++++++++------- okr_module/views/okr_base.xml | 14 +++++++++++--- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/okr_module/__init__.py b/okr_module/__init__.py index 9a7e03ed..0650744f 100644 --- a/okr_module/__init__.py +++ b/okr_module/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/okr_module/__manifest__.py b/okr_module/__manifest__.py index 8a782fb0..ffc09901 100644 --- a/okr_module/__manifest__.py +++ b/okr_module/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'OKR Module', - 'version': '16.0.1.0.0', + 'version': "17.0.1.0.0", 'category': 'Base', 'sequence': 14, 'summary': '', @@ -9,7 +9,7 @@ 'license': 'AGPL-3', 'images': [ ], - 'depends': [ + 'depends': ['contacts' ], 'data': ['security/ir.model.access.csv', 'views/okr_base.xml', @@ -20,4 +20,4 @@ 'installable': True, 'auto_install': False, 'application': True, -} \ No newline at end of file +} diff --git a/okr_module/models/__init__.py b/okr_module/models/__init__.py index 82c4d47c..cb03fb18 100644 --- a/okr_module/models/__init__.py +++ b/okr_module/models/__init__.py @@ -1 +1 @@ -from . import okr_base \ No newline at end of file +from . import okr_base diff --git a/okr_module/models/okr_base.py b/okr_module/models/okr_base.py index 1cf8a47e..06237776 100644 --- a/okr_module/models/okr_base.py +++ b/okr_module/models/okr_base.py @@ -4,19 +4,25 @@ 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 + if sum_weigh>0: + kr.completed_percentage = w_cum/sum_weigh + else: + kr.completed_percentage = 0 else: kr.completed_percentage = 0 @@ -27,8 +33,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') @@ -39,4 +48,3 @@ def _compute_completed_percentage_line(self): kr.completed_percentage = (kr.actual_value/kr.target) else: kr.completed_percentage = 1 - diff --git a/okr_module/views/okr_base.xml b/okr_module/views/okr_base.xml index 795d5be9..358bc0b1 100644 --- a/okr_module/views/okr_base.xml +++ b/okr_module/views/okr_base.xml @@ -16,14 +16,22 @@ okr.base
- - + + + + + + + + + + @@ -40,4 +48,4 @@ - \ No newline at end of file +