[IMP] project: simplify code and improve res.company inherited view

bzr revid: rco@openerp.com-20120625084313-atvbr3hc8940whtt
This commit is contained in:
Raphael Collet
2012-06-25 10:43:13 +02:00
parent 774e54bda1
commit ef87129d69
2 changed files with 13 additions and 22 deletions
+3 -3
View File
@@ -750,9 +750,9 @@
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<page string="Configuration" position="inside">
<separator string="Project Management" colspan="4"/>
<field name="project_time_mode_id" domain="[('category_id','=','Working Time')]"/>
<newline/>
<group string="Project Management">
<field name="project_time_mode_id" domain="[('category_id','=','Working Time')]"/>
</group>
</page>
</field>
</record>
+10 -19
View File
@@ -47,7 +47,7 @@ class project_configuration(osv.osv_memory):
'module_project_issue': fields.boolean("Issues and Bug Tracking",
help="""Provides management of issues/bugs in projects.
This installs the module project_issue."""),
'time_unit': fields.many2one('product.uom', 'Working Time Unit', required=True,
'time_unit': fields.many2one('product.uom', 'Working Time Unit', required=True,
help="""This will set the unit of measure used in projects and tasks."""),
'module_project_issue_sheet': fields.boolean("Track and Invoice Issues Working Time",
help="""Provides timesheet support for the issues/bugs management in project.
@@ -60,25 +60,16 @@ class project_configuration(osv.osv_memory):
help="Allows you to compute Time Estimation on tasks."),
'group_manage_delegation_task': fields.boolean("Manage Task Delegation",
implied_group='project.group_delegate_task',
help="Allows you to delegate tasks to other users."),
help="Allows you to delegate tasks to other users."),
}
def _get_default_time_unit(self, cr, uid, context=None):
res = {}
product_uom_obj = self.pool.get('product.uom')
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
res['time_unit'] = user.company_id.project_time_mode_id.id
return res.get('time_unit', False)
_defaults = {
'time_unit': _get_default_time_unit,
}
def set_project_defaults(self, cr, uid, ids, context=None):
wizard = self.browse(cr, uid, ids)[0]
if wizard.time_unit:
user = self.pool.get('res.users').browse(cr, uid, uid, context)
user.company_id.write({'project_time_mode_id': wizard.time_unit.id})
return {}
def get_default_time_unit(self, cr, uid, fields, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return {'time_unit': user.company_id.project_time_mode_id.id}
def set_time_unit(self, cr, uid, ids, context=None):
config = self.browse(cr, uid, ids[0], context)
user = self.pool.get('res.users').browse(cr, uid, uid, context)
user.company_id.write({'project_time_mode_id': config.time_unit.id})
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: