Merge lp:~openerp-dev/openobject-addons/6.0-opw-574885-han into lp:openobject-addons/6.0

Proposed by Hardik Ansodariya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-574885-han
Merge into: lp:openobject-addons/6.0
Diff against target: 50 lines (+22/-2)
1 file modified
hr_timesheet/wizard/hr_timesheet_sign_in_out.py (+22/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-574885-han
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+109094@code.launchpad.net

Description of the change

Hello,

I have replaced state field from related to function in order to avoid error when write access is not given on relational table.

with reference to Maintenance case: 574885

Thanks

To post a comment you must log in.

Unmerged revisions

5235. By Hardik Ansodariya (OpenERP)

[FIX] hr_timesheet_sign_in_out: Replaced the state field from related to function as it was generating error when write access is not given on relational object

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet/wizard/hr_timesheet_sign_in_out.py'
2--- hr_timesheet/wizard/hr_timesheet_sign_in_out.py 2012-01-18 08:50:14 +0000
3+++ hr_timesheet/wizard/hr_timesheet_sign_in_out.py 2012-06-07 09:45:26 +0000
4@@ -26,6 +26,16 @@
5 class hr_so_project(osv.osv_memory):
6 _name = 'hr.sign.out.project'
7 _description = 'Sign Out By Project'
8+
9+ def _state(self, cr, uid, ids, name, context, *a):
10+ vals = {}
11+ for emp in self.browse(cr, uid, ids, context):
12+ vals[emp.id] = emp.emp_id.state
13+ return vals
14+
15+ #State field is replaced from related to function because when it called from default it was trying to update on
16+ #relational object and when write access is not given on that object it was generating Access Error
17+ #TODO
18 _columns = {
19 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', domain=[('type','=','normal')]),
20 'info': fields.char('Work Description', size=256, required=True),
21@@ -33,7 +43,7 @@
22 'date': fields.datetime('Closing Date'),
23 'analytic_amount': fields.float('Minimum Time Interval', help='This field rounds to the minimum interval specified.\n Example: specify 0.25 and work less than 15 minutes, the working time will be rounded to 15 minutes. If you work 25 minutes, time will be rounded to 30 minutes.'),
24 'name': fields.char('Employees name', size=32, required=True, readonly=True),
25- 'state': fields.related('emp_id', 'state', string='Current state', type='char', required=True, readonly=True),
26+ 'state': fields.function(_state, method=True, string='State', type='char', select=1, size=32),
27 'server_date': fields.datetime('Current Date', required=True, readonly=True),
28 'emp_id': fields.many2one('hr.employee', 'Employee ID')
29 }
30@@ -109,9 +119,19 @@
31
32 _name = 'hr.sign.in.project'
33 _description = 'Sign In By Project'
34+
35+ def _state(self, cr, uid, ids, context, *a):
36+ vals = {}
37+ for emp in self.browse(cr, uid, ids, context):
38+ vals[emp.id] = emp.emp_id.state
39+ return vals
40+
41+ #State field is replaced from related to function because when it called from default it was trying to update on
42+ #relational object and when write access is not given on that object it was generating Access Error
43+ #TODO
44 _columns = {
45 'name': fields.char('Employees name', size=32, readonly=True),
46- 'state': fields.related('emp_id', 'state', string='Current state', type='char', required=True, readonly=True),
47+ 'state': fields.function(_state, method=True, string='State', type='char', select=1, size=32),
48 'date': fields.datetime('Starting Date'),
49 'server_date': fields.datetime('Current Date', readonly=True),
50 'emp_id': fields.many2one('hr.employee', 'Employee ID')