From 828d11348925b0b77ace8e0f47f8ccfe879f3a06 Mon Sep 17 00:00:00 2001 From: jok-adhoc Date: Wed, 1 Nov 2023 17:03:40 -0300 Subject: [PATCH 1/2] Taller Tips & Tricks framework - JOK --- okr_module/__init__.py | 1 + okr_module/__manifest__.py | 23 +++++++++++++ okr_module/models/__init__.py | 1 + okr_module/models/okr_base.py | 42 ++++++++++++++++++++++++ okr_module/security/ir.model.access.csv | 3 ++ okr_module/views/menu.xml | 13 ++++++++ okr_module/views/okr_base.xml | 43 +++++++++++++++++++++++++ 7 files changed, 126 insertions(+) create mode 100644 okr_module/__init__.py create mode 100644 okr_module/__manifest__.py create mode 100644 okr_module/models/__init__.py create mode 100644 okr_module/models/okr_base.py create mode 100644 okr_module/security/ir.model.access.csv create mode 100644 okr_module/views/menu.xml create mode 100644 okr_module/views/okr_base.xml diff --git a/okr_module/__init__.py b/okr_module/__init__.py new file mode 100644 index 00000000..9a7e03ed --- /dev/null +++ b/okr_module/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/okr_module/__manifest__.py b/okr_module/__manifest__.py new file mode 100644 index 00000000..8a782fb0 --- /dev/null +++ b/okr_module/__manifest__.py @@ -0,0 +1,23 @@ +{ + 'name': 'OKR Module', + 'version': '16.0.1.0.0', + 'category': 'Base', + 'sequence': 14, + 'summary': '', + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'images': [ + ], + 'depends': [ + ], + 'data': ['security/ir.model.access.csv', + 'views/okr_base.xml', + 'views/menu.xml', + ], + 'demo': [ + ], + '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 new file mode 100644 index 00000000..82c4d47c --- /dev/null +++ b/okr_module/models/__init__.py @@ -0,0 +1 @@ +from . import okr_base \ No newline at end of file diff --git a/okr_module/models/okr_base.py b/okr_module/models/okr_base.py new file mode 100644 index 00000000..1cf8a47e --- /dev/null +++ b/okr_module/models/okr_base.py @@ -0,0 +1,42 @@ +from odoo import api, models, fields + +class OkrBase(models.Model): + _description = 'OKR BASE' + _name = "okr.base" + + name = fields.Char() + completed_percentage = fields.Float(compute='_compute_completed_percentage') + 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 + for krl in kr.kr_line_ids: + cum += krl.completed_percentage + cant += 1 + kr.completed_percentage = cum/cant + else: + kr.completed_percentage = 0 + + + +class OkrBaseLine(models.Model): + _description = 'OKR LINE' + _name = "okr.base.line" + + name = fields.Char() + okr_base_id = fields.Many2one(comodel_name='okr.base', required=True) + actual_value = fields.Float() + target = fields.Float() + completed_percentage = fields.Float(compute='_compute_completed_percentage_line') + + def _compute_completed_percentage_line(self): + for kr in self: + kr.completed_percentage = 0 + if kr.actual_value>0 and kr.actual_value + + + + diff --git a/okr_module/views/okr_base.xml b/okr_module/views/okr_base.xml new file mode 100644 index 00000000..795d5be9 --- /dev/null +++ b/okr_module/views/okr_base.xml @@ -0,0 +1,43 @@ + + + + Tree OKR + okr.base + + + + + + + + + + Form OKR + okr.base + +
+ + + + + + + + + + + + +
+ + + Menu OKR + okr.base + tree,form + [] + +

Segui tus OKR

+
+
+ +
\ No newline at end of file From b48b94c73b7f491ea403dff7db65217bc5ef1ac7 Mon Sep 17 00:00:00 2001 From: jok-adhoc Date: Thu, 1 Feb 2024 11:13:45 -0300 Subject: [PATCH 2/2] [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/menu.xml | 6 ++++ okr_module/views/okr_base.xml | 63 +++++++++++++++++++++++++++++++++-- 6 files changed, 86 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/menu.xml b/okr_module/views/menu.xml index abbf72e3..f5dbdb26 100644 --- a/okr_module/views/menu.xml +++ b/okr_module/views/menu.xml @@ -10,4 +10,10 @@ action="okr_menu_action" parent="okr_menu" sequence="10"/> + diff --git a/okr_module/views/okr_base.xml b/okr_module/views/okr_base.xml index 795d5be9..e0dece26 100644 --- a/okr_module/views/okr_base.xml +++ b/okr_module/views/okr_base.xml @@ -6,6 +6,20 @@ + + + + + + + + Tree OKR Line + okr.base.line + + + + + @@ -16,20 +30,54 @@ okr.base
- - + + + + + + + + + +
+ + okr.base.search_view + okr.base + + + + + + + + + + + okr.base.line.search_view + okr.base.line + + + + + + + + + + + Menu OKR okr.base @@ -39,5 +87,14 @@

Segui tus OKR

+ + OKR lines + okr.base.line + tree,form + [] + +

Segui tus OKR

+
+
- \ No newline at end of file +