From 0bc433e9ab1d10440ca8f3168ecc3ef94948ea6f Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Tue, 24 Nov 2015 18:16:16 +0000 Subject: [PATCH 1/2] Add base_stage_state --- base_stage_state/README.rst | 91 +++++ base_stage_state/__init__.py | 2 + base_stage_state/__openerp__.py | 31 ++ base_stage_state/models/__init__.py | 3 + base_stage_state/models/base_stage.py | 52 +++ base_stage_state/models/base_stage_mixin.py | 56 +++ base_stage_state/security/ir.model.access.csv | 5 + base_stage_state/views/demo.xml | 258 ++++++++++++ base_stage_state/views/stage_state.xml | 386 ++++++++++++++++++ 9 files changed, 884 insertions(+) create mode 100644 base_stage_state/README.rst create mode 100644 base_stage_state/__init__.py create mode 100644 base_stage_state/__openerp__.py create mode 100644 base_stage_state/models/__init__.py create mode 100644 base_stage_state/models/base_stage.py create mode 100644 base_stage_state/models/base_stage_mixin.py create mode 100644 base_stage_state/security/ir.model.access.csv create mode 100644 base_stage_state/views/demo.xml create mode 100644 base_stage_state/views/stage_state.xml diff --git a/base_stage_state/README.rst b/base_stage_state/README.rst new file mode 100644 index 00000000000..7af268d910f --- /dev/null +++ b/base_stage_state/README.rst @@ -0,0 +1,91 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================= +Stage and Stage support Mixin +============================= + +This module provides a mixin Abstract class to be used by other models. +It will add to the Model all the fields relevant to Kanban boards: + + - ``stage_id`` + - ``state`` + - ``kanban_state`` + - ``color`` + + +Installation +============ + + +To make use of it, you need to add it as a dependency to your module, +and then have your Model inherit from ``base.stage.mixin``. + +The view layer is not provided, so you will also need to add the fields +to the model's views and create your kanban view, if desired. + + +Configuration +============= + +To configure this module, you need to: + +- Create "Stage Sets". Each representes a process pipeline to use in a specific model. +- Create "Stages". Each is a step in a process pipile, and maps to a canonical State. + + +Usage +===== + +Not applicable. + + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/8.0 + + +Known issues / Roadmap +====================== + +* Add UI menu options for the configuration +* Add stage-related statistics, such as time open or days to close. + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Daniel Reis (author) + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/base_stage_state/__init__.py b/base_stage_state/__init__.py new file mode 100644 index 00000000000..a0fdc10fe11 --- /dev/null +++ b/base_stage_state/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/base_stage_state/__openerp__.py b/base_stage_state/__openerp__.py new file mode 100644 index 00000000000..111b64e33fd --- /dev/null +++ b/base_stage_state/__openerp__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright (C) 2016 Daniel Reis +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################### + +{ + 'name': 'Stages and States Mixin', + 'summary': 'Add Stages and Stages to any Model', + 'version': '8.0.1.0.0', + 'category': 'Hidden', + 'author': 'Daniel Reis, Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'depends': ['base'], + 'data': ['security/ir.model.access.csv'], + 'installable': True, +} diff --git a/base_stage_state/models/__init__.py b/base_stage_state/models/__init__.py new file mode 100644 index 00000000000..569455c7f59 --- /dev/null +++ b/base_stage_state/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import base_stage +from . import base_stage_mixin diff --git a/base_stage_state/models/base_stage.py b/base_stage_state/models/base_stage.py new file mode 100644 index 00000000000..08fdff21033 --- /dev/null +++ b/base_stage_state/models/base_stage.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# © 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api + + +class BaseStageSet(models.Model): + """ + Organize Stages in Sets + """ + _name = 'base.stage.set' + _description = 'Base Stage Set' + name = fields.Char(translate=True) + stage_ids = fields.One2many('base.stage', 'stage_set_id', 'Stages') + + +class BaseStage(models.Model): + _name = 'base.stage' + _description = 'Generic Stage' + _order = 'stage_set_id, sequence' + + @api.model + def _get_states(self): + return [ + ('draft', 'New'), + ('open', 'In Progress'), + ('pending', 'Pending'), + ('done', 'Done'), + ('cancelled', 'Cancelled')] + + @api.model + def get_default_stage(self, model): + domain = [('model_id', '=', model), ('fold', '=', False)] + return self.search(domain, limit=1) + + stage_set_id = fields.Many2one( + 'base.stage.set', 'Stage Set', required=True) + sequence = fields.Integer('Sequence', default=1, index=True) + name = fields.Char('Stage Name', required=True, translate=True) + description = fields.Text('Description') + case_default = fields.Boolean( + 'Default for New Projects', + help="When checked, this stage will be proposed by default.") + fold = fields.Boolean( + 'Folded in Kanban View', + help='This stage is folded in the kanban view when' + 'there are no records in that stage to display.') + state = fields.Selection( + _get_states, string="State", + help="Common canonical stages easier to use " + "in custom business logic.") diff --git a/base_stage_state/models/base_stage_mixin.py b/base_stage_state/models/base_stage_mixin.py new file mode 100644 index 00000000000..f090085f5aa --- /dev/null +++ b/base_stage_state/models/base_stage_mixin.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# © 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from openerp import models, fields, api + + +class BaseStageMixin(models.AbstractModel): + _name = "base.stage.mixin" + _description = "Stage Aware Model" + + @api.model + def _get_default_stage(self): + """ Gives default stage_id """ + return self.env['base.stages'].get_default_stage(self._name) + + stage_id = fields.Many2one( + 'base.stage', 'Stage', + track_visibility='always', index=True, + domain="[('model_name', '=', self._name)]", + default=_get_default_stage, + copy=False) + state = fields.Selection( + related='stage_id.state', readonly=True, store=True) + + # Kanban fields + kanban_state = fields.Selection( + [('normal', 'Normal'), + ('blocked', 'Blocked'), + ('done', 'Ready for next stage')], + 'Kanban State', + track_visibility='onchange', + default='normal', + copy=False, + help="The kanban state indicates the workflow readiness:\n" + " * Normal is the default situation\n" + " * Blocked indicates something is preventing progress\n" + " * Ready for next stage indicates it is ready" + " to be pulled to the next stage") + color = fields.Integer('Color Index') + + @api.multi + def _read_group_stage_ids(self, domain, + read_group_order=None, access_rights_uid=None): + stage_sets = self.mapped('stage_id.stage_set_id') + domain = [('stage_set_id', 'in', stage_sets)] + stages = self.stage_ids._search( + domain, access_rights_uid=access_rights_uid) + result = [(x.id, x.display_name) for x in stages] + fold = {x.id: x.fold for x in stages} + return result, fold + + _group_by_full = { + 'stage_id': _read_group_stage_ids, + } diff --git a/base_stage_state/security/ir.model.access.csv b/base_stage_state/security/ir.model.access.csv new file mode 100644 index 00000000000..4610339b15e --- /dev/null +++ b/base_stage_state/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_stage_user,base.stage.user,model_base_stage,base.group_user,1,0,0,0 +access_stage_set_user,base.stage.set.user,model_base_stage_set,base.group_user,1,0,0,0 +access_stage_system,base.stage.system,model_base_stage,base.group_system,1,1,1,1 +access_stage_set_system,base.stage.set.system,model_base_stage_set,base.group_system,1,1,1,1 diff --git a/base_stage_state/views/demo.xml b/base_stage_state/views/demo.xml new file mode 100644 index 00000000000..7da36f1d4c6 --- /dev/null +++ b/base_stage_state/views/demo.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + Little problem + + + PBCK + + + Deadly bug + + + + + + 0 + + + + + + + Bug in Accounts module + agr@agrolait.com + + + + + + + 1 + + + + + + Program not giving proper output + + + + + + + 0 + + + + + + Output incorrect + + + + + + + 1 + + + + + + + Problem loading page + + + + + + 1 + + + + + + + Page not Found + + + + + + 1 + + + + + + + Programming Error + + + + + + + 2 + + + + + + + Logical Error in Program + + + + + + 2 + + + + + + + Constraint Error + + + + + + 2 + + + + + + Error in Program + + + + + + 2 + + + + + + + Patches Error in Program + + + + + + 0 + + + + + + + New Features To Be Added + + + + + + 1 + + + + + + + Add menus to the module + info@opensides.be + + + + + + 1 + + + + + + + Include Attendance sheet in Project + contact@tecsas.fr + + + + + + 1 + + + + + + + Create new object + + + + + + 0 + + + + + + + Improve Reports in HRMS + + + + + + 2 + + + + + + + Improve Reports in PMS + + + + + + + + diff --git a/base_stage_state/views/stage_state.xml b/base_stage_state/views/stage_state.xml new file mode 100644 index 00000000000..97f9c14294c --- /dev/null +++ b/base_stage_state/views/stage_state.xml @@ -0,0 +1,386 @@ + + + + + + + + Issue Version + project.issue.version + + + + + + + + + Issue Version + project.issue.version + +
+ + + + +
+
+
+ + Versions + project.issue.version + form + +

+ Click to add a new version. +

+ Define here the different versions of your products on which + you can work on issues. +

+
+
+ + + + + Project Issue Tracker Form + project.issue + +
+
+ +
+ +
+ +
+
+
+ + +
+
+
+
+ + + Project Issue Tracker Tree + project.issue + + + + + + + + + + + + + + + + + + + + + Project Issue Tracker Search + project.issue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Project Issue Tracker Calendar + project.issue + + + + + + + + + + + + + + Project Issue Kanban + project.issue + + + + + + + + + + + +
    +
  • Project:
  • +
  • Category:
  • +
+
+ +
+
+ i +
+
+
+
+
+ +
+
+ +
+ + +
+
+ +
+
+
+
+
+
+
+
+ + + Project Issue Tracker Graph + project.issue + + + + + + + + + + + + Project Issue- Feature Tracker Tree + project.issue + + + + + + + + + + + + + + + + project.issue + form + Issues + kanban,tree,form,calendar,graph + { + 'search_default_project_id': [active_id], + 'default_project_id': active_id, + } + + +

+ The Odoo issues tacker allows you to efficiantly manage things + like internal requests, software development bugs, customer + complaints, project troubles, material breakdowns, etc. +

+
+
+ + + + project.project.form.inherited + project.project + + + + + + + + + + {'invisible': [('use_tasks', '=', False),('use_issues','=',False)]} + + + {'on_change': 'on_change_use_tasks_or_issues(use_tasks, use_issues)'} + + + + + + + + + project.project.kanban.inherited + project.project + + + + + + + + + Issues + + + + + + + account.analytic.account.issue.form.inherit + account.analytic.account + + + + + + + + + + + project.issue + form + Issues + kanban,tree,form,calendar,graph + +

+ The Odoo issues tacker allows you to efficiantly manage things + like internal requests, software development bugs, customer + complaints, project troubles, material breakdowns, etc. +

+
+
+ + + + res.partner.issues.button.view + res.partner + + + + + + + + + + + +
+
From 04e64d6a61c9a526eac4b98ee3364d8a85acbe4f Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Fri, 27 May 2016 14:54:02 +0100 Subject: [PATCH 2/2] wip --- base_stage_state/__openerp__.py | 5 ++++- base_stage_state/views/menu.xml | 16 ++++++++++++++++ base_stage_state/views/stage_state.xml | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 base_stage_state/views/menu.xml diff --git a/base_stage_state/__openerp__.py b/base_stage_state/__openerp__.py index 111b64e33fd..391c71a0617 100644 --- a/base_stage_state/__openerp__.py +++ b/base_stage_state/__openerp__.py @@ -26,6 +26,9 @@ 'author': 'Daniel Reis, Odoo Community Association (OCA)', 'license': 'AGPL-3', 'depends': ['base'], - 'data': ['security/ir.model.access.csv'], + 'data': [ + 'security/ir.model.access.csv', + 'views/menu.xml', + ], 'installable': True, } diff --git a/base_stage_state/views/menu.xml b/base_stage_state/views/menu.xml new file mode 100644 index 00000000000..fe64f767269 --- /dev/null +++ b/base_stage_state/views/menu.xml @@ -0,0 +1,16 @@ + + + + + + Generic Stage Sets + base.stage.set + form + tree,form + + + + + + diff --git a/base_stage_state/views/stage_state.xml b/base_stage_state/views/stage_state.xml index 97f9c14294c..7d2ffa7f4b6 100644 --- a/base_stage_state/views/stage_state.xml +++ b/base_stage_state/views/stage_state.xml @@ -14,7 +14,7 @@ - + Issue Version project.issue.version