From b4b8f98187821b93ea073b1a83495c18222da9ad Mon Sep 17 00:00:00 2001 From: mav-adhoc Date: Thu, 11 Jan 2024 12:30:39 -0300 Subject: [PATCH 1/3] [TEST] okr: okr by mav --- okr/README.rst | 0 okr/__init__.py | 1 + okr/__manifest__.py | 16 +++++++++++++ okr/ir.model.access.csv | 2 ++ okr/models/__init__.py | 1 + okr/models/okr.py | 30 ++++++++++++++++++++++++ okr/views/okr_views.xml | 51 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 101 insertions(+) create mode 100644 okr/README.rst create mode 100644 okr/__init__.py create mode 100644 okr/__manifest__.py create mode 100644 okr/ir.model.access.csv create mode 100644 okr/models/__init__.py create mode 100644 okr/models/okr.py create mode 100644 okr/views/okr_views.xml diff --git a/okr/README.rst b/okr/README.rst new file mode 100644 index 00000000..e69de29b diff --git a/okr/__init__.py b/okr/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/okr/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/okr/__manifest__.py b/okr/__manifest__.py new file mode 100644 index 00000000..a7b7e232 --- /dev/null +++ b/okr/__manifest__.py @@ -0,0 +1,16 @@ +{ + "name": "OKR", + "author": "Adhoc SA", + "version": "16.0.1.0", + "depends": [ + 'base', + ], + "views":[ + 'security/ir.model.access.csv', + 'views/okr_views.xml.xml', + ], + "license": "AGPL-3", + "installable": True, + "auto_install": False, + "application": True, +} diff --git a/okr/ir.model.access.csv b/okr/ir.model.access.csv new file mode 100644 index 00000000..5d1745e5 --- /dev/null +++ b/okr/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +okr_security,okr_security,okr.model_okr,base.group_user,1,1,1,1 diff --git a/okr/models/__init__.py b/okr/models/__init__.py new file mode 100644 index 00000000..daf566ba --- /dev/null +++ b/okr/models/__init__.py @@ -0,0 +1 @@ +from . import okr diff --git a/okr/models/okr.py b/okr/models/okr.py new file mode 100644 index 00000000..6d21dec0 --- /dev/null +++ b/okr/models/okr.py @@ -0,0 +1,30 @@ +from odoo import models,fields +from datetime import date + +class OKR(models.Model): + _name = 'okr' + _description= 'Okr Management' + + name = fields.Char(required=True) + description = fields.Char() + company_id = fields.Many2one('res.company') + responsible = fields.Many2one('res.users', required=True) + date_start = fields.Date(required=True, default=date.today()) + date_end = fields.Date(required=True) + priority = fields.Selection([ + ('very_high', 'Muy Alta'), + ('high', 'ALta'), + ('medium', 'Media'), + ('low', 'Baja'), + ('very_low', 'Muy Baja'), + ], required=True) + target = fields.Float(required=True) + target_uom = fields.Selection([ + ('percentaje', '%'), + ('units', 'Unidades'), + ('score', 'Puntaje'), + ('success', 'Casos de Éxito'), + ('sla', 'SLA'), + ('error', 'Errores'), + ], string='Unit of Measure', required=True) + result = fields.Float(required=True) diff --git a/okr/views/okr_views.xml b/okr/views/okr_views.xml new file mode 100644 index 00000000..bf1cf149 --- /dev/null +++ b/okr/views/okr_views.xml @@ -0,0 +1,51 @@ + + + + + okr.view.form + okr + +
+ + + + + + + + + + + + + + + + +
+
+
+ + + okr.view.tree + okr + + + + + + + + + + + + + + + okr + okr + form,tree + + +
From 4be2aebaa60a51c73e7d7eff76b9528473ec93fc Mon Sep 17 00:00:00 2001 From: mav-adhoc Date: Thu, 11 Jan 2024 12:33:12 -0300 Subject: [PATCH 2/3] [TEST] okr by mav --- okr/__manifest__.py | 5 +- okr/ir.model.access.csv | 5 +- okr/models/__init__.py | 3 +- okr/models/{okr.py => okr_key_result.py} | 19 +++++--- okr/models/okr_objective.py | 17 +++++++ ...okr_views.xml => okr_key_result_views.xml} | 38 ++++++++------- okr/views/okr_objective_views.xml | 47 +++++++++++++++++++ 7 files changed, 105 insertions(+), 29 deletions(-) rename okr/models/{okr.py => okr_key_result.py} (62%) create mode 100644 okr/models/okr_objective.py rename okr/views/{okr_views.xml => okr_key_result_views.xml} (50%) create mode 100644 okr/views/okr_objective_views.xml diff --git a/okr/__manifest__.py b/okr/__manifest__.py index a7b7e232..7d23bd94 100644 --- a/okr/__manifest__.py +++ b/okr/__manifest__.py @@ -7,10 +7,11 @@ ], "views":[ 'security/ir.model.access.csv', - 'views/okr_views.xml.xml', + 'views/okr_key_result_views.xml', + 'views/okr_objective_views.xml.xml', ], "license": "AGPL-3", "installable": True, "auto_install": False, - "application": True, + "application": False, } diff --git a/okr/ir.model.access.csv b/okr/ir.model.access.csv index 5d1745e5..e4666e16 100644 --- a/okr/ir.model.access.csv +++ b/okr/ir.model.access.csv @@ -1,2 +1,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -okr_security,okr_security,okr.model_okr,base.group_user,1,1,1,1 +access_okr_key_result,access_okr_key_result,model_okr_key_result,okr_key_result_user,1,0,0,0 +access_okr_key_result,access_okr_key_result,model_okr_key_result,okr_key_result_manager,1,1,1,1 +access_okr_objective,access_okr_objective,model_okr_objective,okr_objective_user,1,0,0,0 +access_okr_objective,access_okr_objective,model_okr_objective,okr_objective_manager,1,1,1,1 diff --git a/okr/models/__init__.py b/okr/models/__init__.py index daf566ba..f6a5b83b 100644 --- a/okr/models/__init__.py +++ b/okr/models/__init__.py @@ -1 +1,2 @@ -from . import okr +from . import okr_objective +from . import okr_key_result diff --git a/okr/models/okr.py b/okr/models/okr_key_result.py similarity index 62% rename from okr/models/okr.py rename to okr/models/okr_key_result.py index 6d21dec0..4f540cb1 100644 --- a/okr/models/okr.py +++ b/okr/models/okr_key_result.py @@ -1,16 +1,14 @@ -from odoo import models,fields +from odoo import models, fields, api from datetime import date -class OKR(models.Model): - _name = 'okr' - _description= 'Okr Management' +class OkrKeyResult(models.Model): + _name = 'okr.key.result' + _description= 'OKR Key Result' name = fields.Char(required=True) description = fields.Char() - company_id = fields.Many2one('res.company') responsible = fields.Many2one('res.users', required=True) - date_start = fields.Date(required=True, default=date.today()) - date_end = fields.Date(required=True) + objective = fields.Many2one('okr.objective', required=True) priority = fields.Selection([ ('very_high', 'Muy Alta'), ('high', 'ALta'), @@ -28,3 +26,10 @@ class OKR(models.Model): ('error', 'Errores'), ], string='Unit of Measure', required=True) result = fields.Float(required=True) + progress = fields.Float(compute="_compute_progress") + comments = fields.Text() + + @api.depends('result', 'target') + def _compute_progress(self): + for rec in self: + rec.progress = (rec.result / rec.target)*100 diff --git a/okr/models/okr_objective.py b/okr/models/okr_objective.py new file mode 100644 index 00000000..3d3e5289 --- /dev/null +++ b/okr/models/okr_objective.py @@ -0,0 +1,17 @@ +from odoo import models, fields +from datetime import date + +class OkrObjective(models.Model): + _name = 'okr.objective' + _description= 'OKR Objective' + + name = fields.Char(required=True) + description = fields.Char() + company_id = fields.Many2one('res.company') + responsible = fields.Many2one('res.users', required=True) + date_start = fields.Date(required=True, default=date.today()) + date_end = fields.Date(required=True) + type = fields.Selection([ + ('commitment', 'Commitment'), + ('inspirational', 'Inspirational'),]) + comments = fields.Text() diff --git a/okr/views/okr_views.xml b/okr/views/okr_key_result_views.xml similarity index 50% rename from okr/views/okr_views.xml rename to okr/views/okr_key_result_views.xml index bf1cf149..f2b7c615 100644 --- a/okr/views/okr_views.xml +++ b/okr/views/okr_key_result_views.xml @@ -1,51 +1,53 @@ - - okr.view.form - okr + + okr.key.result.view.form + okr.key.result
- + + - - - - - + + + +
- - okr.view.tree - okr + + okr.key.result.view.tree + okr.key.result + - - + - - okr - okr - form,tree + + okr key result + okr.key.result + tree,form + +
diff --git a/okr/views/okr_objective_views.xml b/okr/views/okr_objective_views.xml new file mode 100644 index 00000000..2e36de70 --- /dev/null +++ b/okr/views/okr_objective_views.xml @@ -0,0 +1,47 @@ + + + + + okr.objective.view.form + okr.objective + +
+ + + + + + + + + + + + +
+
+
+ + + okr.objective.view.tree + okr.objective + + + + + + + + + + + + + okr objective + okr.objective + tree,form + + + + +
From 9492826b0816ed974d80555e584d3b577e17d68b Mon Sep 17 00:00:00 2001 From: mav-adhoc Date: Thu, 1 Feb 2024 11:20:24 -0300 Subject: [PATCH 3/3] [MIG] okr: Migration to 17.0 --- okr/__manifest__.py | 9 +++++---- okr/ir.model.access.csv | 5 ----- okr/models/okr_key_result.py | 5 ++++- okr/security/ir.model.access.csv | 3 +++ okr/views/okr_key_result_views.xml | 10 ++++++---- okr/views/okr_objective_views.xml | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 okr/ir.model.access.csv create mode 100644 okr/security/ir.model.access.csv diff --git a/okr/__manifest__.py b/okr/__manifest__.py index 7d23bd94..0f1fe453 100644 --- a/okr/__manifest__.py +++ b/okr/__manifest__.py @@ -1,17 +1,18 @@ { "name": "OKR", "author": "Adhoc SA", - "version": "16.0.1.0", + "version": "17.0.1.0.0", "depends": [ 'base', + 'hr', ], - "views":[ + "data": [ 'security/ir.model.access.csv', + 'views/okr_objective_views.xml', 'views/okr_key_result_views.xml', - 'views/okr_objective_views.xml.xml', ], "license": "AGPL-3", "installable": True, "auto_install": False, - "application": False, + "application": True, } diff --git a/okr/ir.model.access.csv b/okr/ir.model.access.csv deleted file mode 100644 index e4666e16..00000000 --- a/okr/ir.model.access.csv +++ /dev/null @@ -1,5 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_okr_key_result,access_okr_key_result,model_okr_key_result,okr_key_result_user,1,0,0,0 -access_okr_key_result,access_okr_key_result,model_okr_key_result,okr_key_result_manager,1,1,1,1 -access_okr_objective,access_okr_objective,model_okr_objective,okr_objective_user,1,0,0,0 -access_okr_objective,access_okr_objective,model_okr_objective,okr_objective_manager,1,1,1,1 diff --git a/okr/models/okr_key_result.py b/okr/models/okr_key_result.py index 4f540cb1..9c3e4145 100644 --- a/okr/models/okr_key_result.py +++ b/okr/models/okr_key_result.py @@ -32,4 +32,7 @@ class OkrKeyResult(models.Model): @api.depends('result', 'target') def _compute_progress(self): for rec in self: - rec.progress = (rec.result / rec.target)*100 + if rec.target: + rec.progress = (rec.result / rec.target)*100 + else: + rec.progress = 0 diff --git a/okr/security/ir.model.access.csv b/okr/security/ir.model.access.csv new file mode 100644 index 00000000..1ef71303 --- /dev/null +++ b/okr/security/ir.model.access.csv @@ -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,model_okr_objective,base.group_user,1,1,1,1 +okr.access_okr_key_result,access_okr_key_result,model_okr_key_result,base.group_user,1,1,1,1 diff --git a/okr/views/okr_key_result_views.xml b/okr/views/okr_key_result_views.xml index f2b7c615..c518fc57 100644 --- a/okr/views/okr_key_result_views.xml +++ b/okr/views/okr_key_result_views.xml @@ -19,9 +19,11 @@ - - - + + + + + @@ -48,6 +50,6 @@ tree,form - + diff --git a/okr/views/okr_objective_views.xml b/okr/views/okr_objective_views.xml index 2e36de70..5264c6ac 100644 --- a/okr/views/okr_objective_views.xml +++ b/okr/views/okr_objective_views.xml @@ -42,6 +42,6 @@ tree,form - +