← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/project-service/project_service_project_closing_vre into lp:project-service

 

Vincent Renaville@camptocamp has proposed merging lp:~camptocamp/project-service/project_service_project_closing_vre into lp:project-service.

Requested reviews:
  Project Core Editors (project-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/project-service/project_service_project_closing_vre/+merge/219388

Hello,

The module project_closing, allow that an analytic account related to a project is automatically closed.
This feature is to prevent a person to enter time-sheet on a closed project.
-- 
https://code.launchpad.net/~camptocamp/project-service/project_service_project_closing_vre/+merge/219388
Your team Project Core Editors is requested to review the proposed merge of lp:~camptocamp/project-service/project_service_project_closing_vre into lp:project-service.
=== added directory 'project_closing'
=== added file 'project_closing/__init__.py'
--- project_closing/__init__.py	1970-01-01 00:00:00 +0000
+++ project_closing/__init__.py	2014-05-13 15:08:57 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013 Camptocamp Author Vincent Renaville
+#    
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import project
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'project_closing/__openerp__.py'
--- project_closing/__openerp__.py	1970-01-01 00:00:00 +0000
+++ project_closing/__openerp__.py	2014-05-13 15:08:57 +0000
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013 Camtpcaomp
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    "name": "Project closing",
+    "version": "1.1dr",
+    "author": "Camptocamp",
+    "website": "http://www.camptocamp.com";,
+    "category": "project Management",
+    "depends": ["project"],
+    "description": """\
+Automatic account analytic closing when related project is closed.
+In case of multiple analytic account on a same project, a warning is raise.
+    """,
+    "data": [],
+    'installable': True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'project_closing/project.py'
--- project_closing/project.py	1970-01-01 00:00:00 +0000
+++ project_closing/project.py	2014-05-13 15:08:57 +0000
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+from osv import orm
+
+
+class project_project(orm.Model):
+    _inherit = 'project.project'
+
+    def set_done(self, cr, uid, ids, context=None):
+        ## We will close related analytic account
+        analytic_account_obj = self.pool.get('account.analytic.account')
+        if isinstance(ids, (int, long)):
+            ids = [ids]
+        projects = self.browse(cr, uid, ids, context=context)
+        for project in projects:
+            analytic_account_obj.write(cr, uid,
+                                       [project.analytic_account_id.id],
+                                       {'state': 'close'},
+                                       context=context)
+        return super(project_project, self).set_done(cr, uid, ids,
+                                                     context=context)
+
+    def set_open(self, cr, uid, ids, context=None):
+        ## We will re-open related analytic account
+        analytic_account_obj = self.pool.get('account.analytic.account')
+        if isinstance(ids, (int, long)):
+            ids = [ids]
+        projects = self.browse(cr, uid, ids, context=context)
+        for project in projects:
+            analytic_account_obj.write(cr, uid,
+                                       [project.analytic_account_id.id],
+                                       {'state': 'open'},
+                                       context=context)
+        return super(project_project, self).set_open(cr, uid,
+                                                     ids,
+                                                     context=context)