Merge lp:~camptocamp/project-service/project_service_project_closing_vre into lp:~project-core-editors/project-service/trunk

Proposed by Vincent Renaville@camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/project-service/project_service_project_closing_vre
Merge into: lp:~project-core-editors/project-service/trunk
Diff against target: 108 lines (+93/-0)
3 files modified
project_closing/__init__.py (+25/-0)
project_closing/__openerp__.py (+36/-0)
project_closing/project.py (+32/-0)
To merge this branch: bzr merge lp:~camptocamp/project-service/project_service_project_closing_vre
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp Needs Fixing
Leonardo Pistone code review Needs Fixing
Review via email: mp+219388@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks Vincent.

- 2013 Camtpcaomp => 2014 Camptocamp
- version 1.1dr ?
- "category": "project Management",

- optional: you might find it clearer to do:

project.analytic_account_id.write({'state': 'open'})

calling the magic "write" method on the browse_record instance

review: Needs Fixing (code review)
Revision history for this message
Daniel Reis (dreis-pt) wrote :

Logic sound good for me.

Comments:
L56: could you add "summary" with a short description
L84,L98: you would be better off turning these comments into docstrings

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Agreed with Daniel docstring is the right path to follow.

review: Approve
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) :
review: Needs Fixing
29. By Vincent Renaville@camptocamp on 2014-06-26

[FIX] add docstring + change write syntax + add module summary

Revision history for this message
Vincent Renaville@camptocamp (vrenaville-c2c) wrote :

Hello,

Thanks for the review and sorry for the delay.

I have just fix the modules according to your review.

Vincent

Revision history for this message
Daniel Reis (dreis-pt) wrote :

This project is now hosted on https://github.com/OCA/project-service. Please move your proposal there.
This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

29. By Vincent Renaville@camptocamp on 2014-06-26

[FIX] add docstring + change write syntax + add module summary

28. By Vincent Renaville@camptocamp on 2014-05-13

[FIX] pep8

27. By Vincent Renaville@camptocamp on 2013-10-30

[ADD] project closing module

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'project_closing'
2=== added file 'project_closing/__init__.py'
3--- project_closing/__init__.py 1970-01-01 00:00:00 +0000
4+++ project_closing/__init__.py 2014-06-26 08:44:03 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (C) 2013 Camptocamp Author Vincent Renaville
11+#
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+from . import project
29+
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31
32=== added file 'project_closing/__openerp__.py'
33--- project_closing/__openerp__.py 1970-01-01 00:00:00 +0000
34+++ project_closing/__openerp__.py 2014-06-26 08:44:03 +0000
35@@ -0,0 +1,36 @@
36+# -*- coding: utf-8 -*-
37+##############################################################################
38+#
39+# OpenERP, Open Source Management Solution
40+# Copyright (C) 2013 Camtpcaomp
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+{
57+ "name": "Project closing",
58+ "version": "1.0",
59+ "author": "Camptocamp",
60+ "website": "http://www.camptocamp.com",
61+ "category": "Project Management",
62+ "depends": ["project"],
63+ "summary": "Allow the state to be consistent between project and related analytic account",
64+ "description": """\
65+Automatic account analytic closing when related project is closed.
66+In case of multiple analytic account on a same project, a warning is raise.
67+ """,
68+ "data": [],
69+ 'installable': True,
70+}
71+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
72
73=== added file 'project_closing/project.py'
74--- project_closing/project.py 1970-01-01 00:00:00 +0000
75+++ project_closing/project.py 2014-06-26 08:44:03 +0000
76@@ -0,0 +1,32 @@
77+# -*- coding: utf-8 -*-
78+from osv import orm
79+
80+
81+class project_project(orm.Model):
82+ _inherit = 'project.project'
83+
84+ def set_done(self, cr, uid, ids, context=None):
85+ """
86+ We will close related analytic account
87+ """
88+
89+ if isinstance(ids, (int, long)):
90+ ids = [ids]
91+ projects = self.browse(cr, uid, ids, context=context)
92+ for project in projects:
93+ project.analytic_account_id.write({'state': 'close'},context=context)
94+ return super(project_project, self).set_done(cr, uid, ids,
95+ context=context)
96+
97+ def set_open(self, cr, uid, ids, context=None):
98+ """
99+ We will re-open related analytic account
100+ """
101+ if isinstance(ids, (int, long)):
102+ ids = [ids]
103+ projects = self.browse(cr, uid, ids, context=context)
104+ for project in projects:
105+ project.analytic_account_id.write({'state': 'open'},context=context)
106+ return super(project_project, self).set_open(cr, uid,
107+ ids,
108+ context=context)

Subscribers

People subscribed via source and target branches