diff --git a/project_categ_issue/README.rst b/project_categ_issue/README.rst new file mode 100644 index 0000000000..df8feb0ae0 --- /dev/null +++ b/project_categ_issue/README.rst @@ -0,0 +1,49 @@ +.. 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 + +====================== +Project Category Issue +====================== + +* Adds to Issues the ability to limit selectable Categories to a Project's specific list. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/140/10.0 + +Known issues / Roadmap +====================== + +* + +Bug Tracker +=========== + + + +Credits +======= + +Contributors +------------ +* Daniel Reis +* Rigoberto Martínez + +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/project_categ_issue/__init__.py b/project_categ_issue/__init__.py index c35e9bc054..f25f7adb5f 100644 --- a/project_categ_issue/__init__.py +++ b/project_categ_issue/__init__.py @@ -1,2 +1,6 @@ # -*- coding: utf-8 -*- -from . import project_categ_model +# (c) 2013 Daniel Reis +# (c) 2017 Rigoberto Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models diff --git a/project_categ_issue/__manifest__.py b/project_categ_issue/__manifest__.py index 67d89697b9..227d08d835 100644 --- a/project_categ_issue/__manifest__.py +++ b/project_categ_issue/__manifest__.py @@ -1,40 +1,23 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2013 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 . -# -############################################################################## +# © 2013 Daniel Reis +# © 2017 Rigoberto Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + { 'name': 'Per Project Configurable Categorie on Issues', 'summary': 'Projects Issues can have an allowed category list', - 'version': '8.0.0.1.0', + 'version': '10.0.0.1.0', "category": "Project Management", - 'description': """\ -Adds to Issues the ability to limit selectable Categories to a Proeject's -specific list. -""", - 'author': "Daniel Reis,Odoo Community Association (OCA)", + 'author': "Daniel Reis, Tecnativa, Odoo Community Association (OCA)", + 'website': 'https://www.tecnativa.com', 'license': 'AGPL-3', 'depends': [ 'project_issue', 'project_categ', ], 'data': [ - 'project_categ_view.xml', + 'views/project_categ_view.xml', ], - 'installable': False, + 'installable': True, 'auto_install': True, } diff --git a/project_categ_issue/models/__init__.py b/project_categ_issue/models/__init__.py new file mode 100644 index 0000000000..54bbb58e58 --- /dev/null +++ b/project_categ_issue/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2013 Daniel Reis +# © 2017 Rigoberto Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import project_categ_model \ No newline at end of file diff --git a/project_categ_issue/models/project_categ_model.py b/project_categ_issue/models/project_categ_model.py new file mode 100644 index 0000000000..a73a6e01c4 --- /dev/null +++ b/project_categ_issue/models/project_categ_model.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# © 2013 Daniel Reis +# © 2017 Rigoberto Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, fields, models + + +class ProjectProject(models.Model): + _inherit = 'project.project' + + issue_tag_id = fields.Many2one('project.tags', + string='Root Tag for Issues') + + +class ProjectIssue(models.Model): + _inherit = 'project.issue' + + tag_project = fields.Many2one('project.tags', string='Root Tag for Issues', + compute='_compute_project_root_tag') + + @api.multi + @api.depends('project_id') + def _compute_project_root_tag(self): + for issue in self: + issue.tag_project = issue.project_id.issue_tag_id or False + + @api.onchange('project_id') + def _onchange_project(self): + super(ProjectIssue, self)._onchange_project_id() + self.tag_ids &= self.project_id.issue_tag_id.child_ids diff --git a/project_categ_issue/project_categ_model.py b/project_categ_issue/project_categ_model.py deleted file mode 100644 index d16bb6cdc5..0000000000 --- a/project_categ_issue/project_categ_model.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2013 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 . -# -############################################################################## - -from openerp.osv import fields, orm - - -class ProjectProject(orm.Model): - _inherit = 'project.project' - _columns = { - 'issue_categ_id': fields.many2one( - 'project.category', 'Root Category for Issues'), - } - - -class ProjectIssue(orm.Model): - _inherit = 'project.issue' - - def onchange_project(self, cr, uid, id, project_id, context=None): - # on_change is necessary to populate fields on create, before saving - try: - res = super(ProjectIssue, self).onchange_project( - cr, uid, id, project_id, context) or {} - except AttributeError: - res = {} - - if project_id: - obj = self.pool.get('project.project').browse( - cr, uid, project_id, context=context) - if obj.issue_categ_id: - res.setdefault('value', {}) - res['value']['issue_categ_id'] = obj.issue_categ_id.id - return res - - _columns = { - 'issue_categ_id': fields.related( - 'project_id', 'issue_categ_id', string="Category Root", - type='many2one', relation='project.category', readonly=True), - 'categ_ids': fields.many2many( - 'project.category', string='Tags', - domain="[('id','child_of',issue_categ_id)" - ",('id','!=',issue_categ_id)]"), - } diff --git a/project_categ_issue/project_categ_view.xml b/project_categ_issue/project_categ_view.xml deleted file mode 100644 index 4b949c6719..0000000000 --- a/project_categ_issue/project_categ_view.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - project_form_view_categs - project.project - - - - - - - - - - - project_issue_form_view_categs - project.issue - - - - - onchange_project(project_id) - - - - - - - - {'required':[('issue_categ_id','!=',False)]} - - - - - - - diff --git a/project_categ_issue/views/project_categ_view.xml b/project_categ_issue/views/project_categ_view.xml new file mode 100644 index 0000000000..5392769650 --- /dev/null +++ b/project_categ_issue/views/project_categ_view.xml @@ -0,0 +1,34 @@ + + + + + + project.categ.issue.project.view.form + project.project + + + + + + + + + + + project.categ.issue.project.issue.view.form + project.issue + + + + + + + + + [('id', 'child_of', tag_project),('id','!=',tag_project)] + {'required':[('tag_project','!=',False)]} + + + + +