Merge lp:~openerp-dev/openobject-addons/trunk-bug-798739-mtr into lp:openobject-addons

Proposed by Meera Trambadia (OpenERP)
Status: Merged
Merged at revision: 5308
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-798739-mtr
Merge into: lp:openobject-addons
Diff against target: 97 lines (+15/-15)
1 file modified
hr_holidays/hr_holidays.py (+15/-15)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-798739-mtr
Reviewer Review Type Date Requested Status
qdp (OpenERP) Approve
Mustufa Rangwala (Open ERP) (community) Approve
Meera Trambadia (OpenERP) (community) Needs Resubmitting
tfr (Openerp) (community) Needs Fixing
Review via email: mp+66124@code.launchpad.net

Description of the change

hr_holidays:-Exception raised on confirmation of leave request is now translated in user's lang." --fixes=lp:798739

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

No need to initialize context={}. you can direct write context={'lang': lang}

And No need to check whether context is none or not as you are not using the context below code in check_holidays
+ if context is None:
+ context = {}

Thanks,
mra

review: Needs Fixing
Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello sir,

I have made the changes as mentioned above.

Thanks,
mtr

review: Needs Resubmitting
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

I have improved the code to make generic method to get user lang in context.

Thanks,
mra

review: Approve
Revision history for this message
tfr (Openerp) (tfr) wrote :

Why create a function to get the lang of the res user when this value is already in the context, you just need to replace definition of method and pass the context :

def holidays_validate(self, cr, uid, ids, context=None):
       self.check_holidays(cr, uid, ids, context=context)

review: Needs Fixing
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

As passing context from workflow method does not work.

But after fixing the framework bug: https://bugs.launchpad.net/openobject-server/+bug/710533 workflow will pass the context.

So as per tfr suggestion we can use context now for workflow method instead of args.

Thanks tfr for review,
mra

Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello sir,

I have passed context in the methods as suggested by you.

Thanks,
mtr

review: Needs Resubmitting
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

remove from methods
+ if context is None:
  + context = {}

we can only use it where we are fetching from context dictionary so keep it where its used.

review: Needs Fixing
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

+ <field name="date_from" on_change="onchange_date_from(date_to, date_from, context)" attrs="{'readonly':[('type','=','add')], 'required':[('type','=','remove')]}"/>

why you pass context in onchange ?

review: Needs Information
Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello sir,

I have made changes as suggested by you.

Thanks,
mtr

review: Needs Resubmitting
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) :
review: Approve
Revision history for this message
qdp (OpenERP) (qdp) wrote :

I remove unneeded code in onchanges + optimized a little the refusal. The rest is unchanged and merged. Note that this will only work once the server will propagate the context through the workflow triggers (still planned for 6.1)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_holidays/hr_holidays.py'
2--- hr_holidays/hr_holidays.py 2011-07-08 09:22:32 +0000
3+++ hr_holidays/hr_holidays.py 2011-09-16 05:14:25 +0000
4@@ -161,7 +161,7 @@
5 leave_ids = obj_res_leave.search(cr, uid, [('holiday_id', 'in', ids)], context=context)
6 return obj_res_leave.unlink(cr, uid, leave_ids)
7
8- def onchange_type(self, cr, uid, ids, holiday_type):
9+ def onchange_type(self, cr, uid, ids, holiday_type, context=None):
10 result = {'value': {'employee_id': False}}
11 if holiday_type == 'employee':
12 ids_employee = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
13@@ -172,7 +172,7 @@
14 return result
15
16 # TODO: can be improved using resource calendar method
17- def _get_number_of_days(self, date_from, date_to):
18+ def _get_number_of_days(self, date_from, date_to, context=None):
19 """Returns a float equals to the timedelta between two dates given as string."""
20
21 DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
22@@ -188,10 +188,10 @@
23 raise osv.except_osv(_('Warning!'),_('You cannot delete a leave which is not in draft state !'))
24 return super(hr_holidays, self).unlink(cr, uid, ids, context)
25
26- def onchange_date_from(self, cr, uid, ids, date_to, date_from):
27+ def onchange_date_from(self, cr, uid, ids, date_to, date_from, context=None):
28 result = {}
29 if date_to and date_from:
30- diff_day = self._get_number_of_days(date_from, date_to)
31+ diff_day = self._get_number_of_days(date_from, date_to, context=context)
32 result['value'] = {
33 'number_of_days_temp': round(diff_day)+1
34 }
35@@ -212,7 +212,7 @@
36 }
37 return {'warning': warning}
38
39- def set_to_draft(self, cr, uid, ids, *args):
40+ def set_to_draft(self, cr, uid, ids, context=None):
41 self.write(cr, uid, ids, {
42 'state': 'draft',
43 'manager_id': False,
44@@ -223,15 +223,15 @@
45 wf_service.trg_create(uid, 'hr.holidays', id, cr)
46 return True
47
48- def holidays_validate(self, cr, uid, ids, *args):
49- self.check_holidays(cr, uid, ids)
50+ def holidays_validate(self, cr, uid, ids, context=None):
51+ self.check_holidays(cr, uid, ids, context=context)
52 obj_emp = self.pool.get('hr.employee')
53 ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
54 manager = ids2 and ids2[0] or False
55 return self.write(cr, uid, ids, {'state':'validate1', 'manager_id': manager})
56
57- def holidays_validate2(self, cr, uid, ids, *args):
58- self.check_holidays(cr, uid, ids)
59+ def holidays_validate2(self, cr, uid, ids, context=None):
60+ self.check_holidays(cr, uid, ids, context=context)
61 obj_emp = self.pool.get('hr.employee')
62 ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
63 manager = ids2 and ids2[0] or False
64@@ -276,19 +276,19 @@
65 wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr)
66 return True
67
68- def holidays_confirm(self, cr, uid, ids, *args):
69- self.check_holidays(cr, uid, ids)
70+ def holidays_confirm(self, cr, uid, ids, context=None):
71+ self.check_holidays(cr, uid, ids, context=context)
72 return self.write(cr, uid, ids, {'state':'confirm'})
73
74- def holidays_refuse(self, cr, uid, ids, *args):
75+ def holidays_refuse(self, cr, uid, ids, context=None):
76 obj_emp = self.pool.get('hr.employee')
77 ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
78 manager = ids2 and ids2[0] or False
79 self.write(cr, uid, ids, {'state': 'refuse', 'manager_id2': manager})
80- self.holidays_cancel(cr, uid, ids)
81+ self.holidays_cancel(cr, uid, ids, context=context)
82 return True
83
84- def holidays_cancel(self, cr, uid, ids, *args):
85+ def holidays_cancel(self, cr, uid, ids, context=None):
86 obj_crm_meeting = self.pool.get('crm.meeting')
87 for record in self.browse(cr, uid, ids):
88 # Delete the meeting
89@@ -302,7 +302,7 @@
90
91 return True
92
93- def check_holidays(self, cr, uid, ids):
94+ def check_holidays(self, cr, uid, ids, context=None):
95 holi_status_obj = self.pool.get('hr.holidays.status')
96 for record in self.browse(cr, uid, ids):
97 if record.holiday_type == 'employee' and record.type == 'remove':

Subscribers

People subscribed via source and target branches

to all changes: