Skip to content

Commit 6e3b6a9

Browse files
author
Charbel Jacquin
committed
[WIP][MIG] port project_classification to 8.0
1 parent d6695f4 commit 6e3b6a9

File tree

5 files changed

+52
-31
lines changed

5 files changed

+52
-31
lines changed

__unported__/project_classification/__init__.py project_classification/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
#
2020
##############################################################################
21-
import project_classification
21+
from . import project_classification
2222

2323
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

__unported__/project_classification/__openerp__.py project_classification/__openerp__.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919
#
2020
##############################################################################
2121
{
22-
'name': 'Project classification (easy hierarchy and setup for project managers)',
22+
'name': "Project classification (easy hierarchy and setup "
23+
"for project managers)",
2324
'version': '1.0',
2425
'category': 'Generic Modules/Projects & Services',
2526
'description': """
2627
27-
This Module allow you to setup different project classification to ease the data entry of
28-
new project. The parent project will be set as readonly to forbid users to change it.
29-
The parent is still available through the analytic account object. This is useful because
30-
this way, project manager will setup correctly the analytical account just by choosing the
31-
corresponing classification.
28+
This Module allow you to setup different project classification to ease the
29+
data entry of new project. The parent project will be set as readonly to
30+
forbid users to change it.
31+
32+
The parent is still available through the analytic account object.
33+
This is useful because this way, project manager will setup correctly
34+
the analytical account just by choosing the corresponing classification.
3235
3336
A project classification is composed by :
3437
@@ -52,7 +55,7 @@
5255
],
5356
'demo_xml': [],
5457
'test': [],
55-
'installable': False,
58+
'installable': True,
5659
'auto_install': False,
5760
'application': True,
5861
}

__unported__/project_classification/project_classification.py project_classification/project_classification.py

+39-21
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,31 @@
2020
##############################################################################
2121
from openerp.osv import orm, fields
2222

23+
2324
class ProjectClassification(orm.Model):
2425
_name = "project.classification"
2526
_description = "Project classification"
2627

27-
_columns ={
28+
_columns = {
2829
'name': fields.char('Classification Name', required=True, size=64),
29-
'project_id':fields.many2one('account.analytic.account', 'Parent project', help="The parent\
30-
project that will be set when choosing this classification in a project.", required=True),
31-
'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Reinvoice Costs',
32-
help="Fill this field if you plan to automatically generate invoices based " \
33-
"on the costs in this classification"),
30+
'project_id':
31+
fields.many2one('account.analytic.account',
32+
'Parent project',
33+
help="The parent project that will be set when "
34+
"choosing this classification in a project.",
35+
required=True),
36+
'to_invoice': fields.many2one('hr_timesheet_invoice.factor',
37+
'Reinvoice Costs',
38+
help="Fill this field if you plan to "
39+
"automatically generate invoices based "
40+
"on the costs in this classification"),
3441
'currency_id': fields.many2one('res.currency', 'Currency'),
3542
'user_id': fields.many2one('res.users', 'Account Manager'),
36-
'pricelist_id': fields.many2one('product.pricelist', 'Sale Pricelist',),
43+
'pricelist_id': fields.many2one('product.pricelist',
44+
'Sale Pricelist',),
3745
}
3846

47+
3948
class ProjectProject(orm.Model):
4049
_inherit = "project.project"
4150

@@ -52,24 +61,33 @@ def _child_project_compute(self, cr, uid, ids, name, arg, context=None):
5261
continue
5362
child_projects += account_child.project_ids
5463

55-
result[project.id] = [child_project.id for child_project in child_projects]
64+
result[project.id] = [child_project.id for child_project
65+
in child_projects]
5666
return result
5767

5868
def onchange_classification_id(self, cr, uid, ids, classification_id):
59-
classification = self.pool.get('project.classification').browse(cr, uid, classification_id)
60-
return {'value':{
61-
'parent_id': classification.project_id.id,
62-
'to_invoice': classification.to_invoice.id or False,
63-
'currency_id': classification.currency_id.id or False,
64-
'user_id': classification.user_id.id or False,
65-
'pricelist_id': classification.pricelist_id.id or False,
66-
}}
69+
projclass = self.pool.get('project.classification')
70+
classification = projclass.browse(cr, uid, classification_id)
71+
return {'value':
72+
{'parent_id': classification.project_id.id,
73+
'to_invoice': classification.to_invoice.id or False,
74+
'currency_id': classification.currency_id.id or False,
75+
'user_id': classification.user_id.id or False,
76+
'pricelist_id': classification.pricelist_id.id or False}}
6777

68-
_columns ={
69-
'classification_id':fields.many2one('project.classification', 'Classification', help="This will automatically set the parent "\
70-
"project as well as other default values define for this kind project (like pricelist, invoice factor,..)", required=True),
71-
'child_project_complete_ids': fields.function(_child_project_compute,
72-
relation='project.project', method=True, string="Project Hierarchy", type='many2many'),
78+
_columns = {
79+
'classification_id':
80+
fields.many2one('project.classification', 'Classification',
81+
help="This will automatically set the parent "
82+
"project as well as other default values define "
83+
"for this kind project (like pricelist, "
84+
"invoice factor,..)",
85+
required=True),
86+
'child_project_complete_ids':
87+
fields.function(_child_project_compute,
88+
relation='project.project',
89+
method=True,
90+
string="Project Hierarchy", type='many2many'),
7391
}
7492

7593
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

__unported__/project_classification/project_classification_view.xml project_classification/project_classification_view.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
<field name="model">project.project</field>
4747
<field name="inherit_id" ref="project.edit_project" />
4848
<field name="arch" type="xml">
49-
<xpath expr="/form/sheet/notebook/page[@string='Other Info']/group/group[3]/field[@name='parent_id']" position="replace">
49+
<xpath expr="/form//page[@string='Other Info']//field[@name='parent_id']" position="replace">
5050
<field name="classification_id" widget="selection" on_change="onchange_classification_id(classification_id)"/>
5151
</xpath>
52-
<xpath expr="/form/sheet/notebook/page[@string='Other Info']/group/group[3]/field[@name='currency_id']" position="after">
52+
<xpath expr="/form//page[@string='Other Info']//field[@name='currency_id']" position="after">
5353
<field name="pricelist_id" domain="[('type','=','sale')]" widget="selection"/>
5454
<!-- <field name="to_invoice" /> -->
5555
<field name="parent_id" string="Parent Project" domain="[('id','!=',active_id)]" context="{'current_model': 'project.project'}" />

0 commit comments

Comments
 (0)