diff --git a/addons/project/project.py b/addons/project/project.py index debeefa9f1f..080e72f7678 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -898,18 +898,23 @@ class task(base_stage, osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): users_obj = self.pool.get('res.users') if context is None: context = {} - # read uom as admin to avoid access rights issues, e.g. for portal/share users, - # this should be safe (no context passed to avoid side-effects) - obj_tm = users_obj.browse(cr, SUPERUSER_ID, uid, context=context).company_id.project_time_mode_id - tm = obj_tm and obj_tm.name or 'Hours' res = super(task, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu) - if tm in ['Hours','Hour']: + # read uom as admin to avoid access rights issues, e.g. for portal/share users, + # this should be safe (no context passed to avoid side-effects) + obj_tm = users_obj.browse(cr, SUPERUSER_ID, uid, context=context).company_id.project_time_mode_id + try: + # using get_object to get translation value + uom_hour = self.pool['ir.model.data'].get_object(cr, uid, 'product', 'product_uom_hour', context=context) + except ValueError: + uom_hour = False + if not obj_tm or not uom_hour or obj_tm.id == uom_hour.id: return res eview = etree.fromstring(res['arch']) + # if the project_time_mode_id is not in hours (so in days), display it as a float field def _check_rec(eview): if eview.attrib.get('widget','') == 'float_time': eview.set('widget','float') @@ -921,9 +926,13 @@ class task(base_stage, osv.osv): res['arch'] = etree.tostring(eview) + # replace reference of 'Hours' to 'Day(s)' for f in res['fields']: + # TODO this NOT work in different language than english + # the field 'Initially Planned Hours' should be replaced by 'Initially Planned Days' + # but string 'Initially Planned Days' is not available in translation if 'Hours' in res['fields'][f]['string']: - res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm) + res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours', obj_tm.name) return res # ----------------------------------------