[FIX] project_issue: Allow portal customer to see their own issues

Some computed fields have been added in v9 and are calling the method
_compute_day. This method accesses the project related to the issue
So a user portal is able to see his own issue, but cannot open the
form view as the prefetching is loading the fields. Hiding them in
the group base.group_user doesn't have any effect as the compute method
is called on the read. These information may have their importance to
the customer too.

We decided to compute these fields on superuser access rights.

Also the field project_id is displayed on the project_issue form view.
As this information is internal, we're hiding this also under the employee
group.
This commit is contained in:
Yannick Tivisse
2016-03-07 14:24:18 +01:00
parent f7c4b5b65e
commit 271840a282
2 changed files with 16 additions and 9 deletions
+12 -6
View File
@@ -133,7 +133,8 @@ class project_issue(osv.Model):
'create_date': fields.datetime('Creation Date', readonly=True, select=True),
'write_date': fields.datetime('Update Date', readonly=True),
'days_since_creation': fields.function(_compute_day, string='Days since creation date', \
multi='compute_day', type="integer", help="Difference in days between creation date and current date"),
multi='compute_day', type="integer", help="Difference in days between creation date and current date",
groups='base.group_user'),
'date_deadline': fields.date('Deadline'),
'team_id': fields.many2one('crm.team', 'Sales Team', oldname='section_id',\
select=True, help='Sales team to which Case belongs to.\
@@ -167,19 +168,24 @@ class project_issue(osv.Model):
help="You can link this issue to an existing task or directly create a new one from here"),
'day_open': fields.function(_compute_day, string='Days to Assign',
multi='compute_day', type="float",
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)}),
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)},
groups='base.group_user'),
'day_close': fields.function(_compute_day, string='Days to Close',
multi='compute_day', type="float",
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)}),
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)},
groups='base.group_user'),
'user_id': fields.many2one('res.users', 'Assigned to', required=False, select=1, track_visibility='onchange'),
'working_hours_open': fields.function(_compute_day, string='Working Hours to assign the Issue',
multi='compute_day', type="float",
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)}),
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)},
groups='base.group_user'),
'working_hours_close': fields.function(_compute_day, string='Working Hours to close the Issue',
multi='compute_day', type="float",
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)}),
store={'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)},
groups='base.group_user'),
'inactivity_days': fields.function(_compute_day, string='Days since last action',
multi='compute_day', type="integer", help="Difference in days between last action and current date"),
multi='compute_day', type="integer", help="Difference in days between last action and current date",
groups='base.group_user'),
'color': fields.integer('Color Index'),
'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True),
'date_action_last': fields.datetime('Last Action', readonly=1),
+4 -3
View File
@@ -33,7 +33,8 @@
<group>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="email_from"/>
<field name="project_id" on_change="on_change_project(project_id)" context="{'default_use_issues':1}"/>
<field name="project_id" on_change="on_change_project(project_id)" context="{'default_use_issues':1}"
groups="base.group_user"/>
<field name="task_id" groups="base.group_no_one" on_change="onchange_task_id(task_id)" context="{'default_project_id':project_id}"/>
</group>
</group>
@@ -76,7 +77,7 @@
<field name="id"/>
<field name="name"/>
<field name="partner_id"/>
<field name="project_id"/>
<field name="project_id" groups="base.group_user"/>
<field name="priority" string="Priority" groups="base.group_user"/>
<field name="create_date"/>
<field name="user_id"/>
@@ -96,7 +97,7 @@
<field name="id"/>
<field name="partner_id" operator="child_of"/>
<field name="user_id"/>
<field name="project_id"/>
<field name="project_id" groups="base.group_user"/>
<field name="tag_ids"/>
<field name="stage_id" domain="[]"/>
<filter string="My Issues" domain="[('user_id','=',uid)]"/>