openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #00246
[Merge] lp:~openerp-dev/openobject-addons/pso-dev-addons3 into lp:~openerp-dev/openobject-addons/trunk-dev-addons3
pso (Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/pso-dev-addons3 into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
#669360 hr_timeeshet_sheet : installation fails on 1st (and probably last) date of the month.
https://bugs.launchpad.net/bugs/669360
#669533 [hr_timesheet] Employee timesheet reports confuse employee id and user id
https://bugs.launchpad.net/bugs/669533
Hello,
I have applied patch for bug of employee timesheet reports (confusion between employee and user).
https://bugs.launchpad.net/openobject-addons/+bug/669533
Thank you,
pso
--
https://code.launchpad.net/~openerp-dev/openobject-addons/pso-dev-addons3/+merge/39846
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/pso-dev-addons3.
=== modified file 'hr_timesheet/report/user_timesheet.py'
--- hr_timesheet/report/user_timesheet.py 2010-10-09 05:27:04 +0000
+++ hr_timesheet/report/user_timesheet.py 2010-11-02 13:58:46 +0000
@@ -44,6 +44,12 @@
def create_xml(self, cr, uid, ids, data, context):
+ # Get the user id from the selected employee record
+ emp_id = data['form']['employee_id']
+ emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
+ user_id = emp_obj.browse(cr, uid, emp_id).user_id.id
+ empl_name = emp_obj.browse(cr, uid, emp_id).name
+
# Computing the dates (start of month: som, and end of month: eom)
som = datetime.date(data['form']['year'], data['form']['month'], 1)
eom = som + datetime.timedelta(lengthmonth(som.year, som.month))
@@ -63,7 +69,7 @@
"and product_uom_id = unit.id "\
"and line.user_id=%s and line.date >= %s and line.date < %s "
"order by line.date",
- (uid, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d')))
+ (user_id, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d')))
# Sum attendence by account, then by day
accounts = {}
@@ -84,7 +90,7 @@
<date>%s</date>
<company>%s</company>
</header>
- ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
+ ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,user_id).company_id.name)
account_xml = []
for account, telems in accounts.iteritems():
@@ -96,10 +102,6 @@
account_xml.append('\n'.join([xml % (day, amount) for day, amount in telems.iteritems()]))
account_xml.append('</account>')
- # Computing the employee
- cr.execute("select name from res_users where id=%s", (str(uid)))
- emp = cr.fetchone()[0]
-
# Computing the xml
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
<report>
@@ -107,7 +109,7 @@
<employee>%s</employee>
%s
</report>
- ''' % (header_xml,toxml(emp), '\n'.join(date_xml) + '\n'.join(account_xml))
+ ''' % (header_xml,toxml(empl_name), '\n'.join(date_xml) + '\n'.join(account_xml))
return xml
report_custom('report.hr.analytical.timesheet', 'hr.employee', '', 'addons/hr_timesheet/report/user_timesheet.xsl')
=== modified file 'hr_timesheet/report/users_timesheet.py'
--- hr_timesheet/report/users_timesheet.py 2010-10-09 05:27:04 +0000
+++ hr_timesheet/report/users_timesheet.py 2010-11-02 13:58:46 +0000
@@ -33,7 +33,7 @@
return 29
return [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
-def emp_create_xml(cr, id, som, eom):
+def emp_create_xml(cr, id, som, eom, emp):
# Computing the attendence by analytical account
cr.execute(
"select line.date, (unit_amount * unit.factor) as amount "\
@@ -58,10 +58,6 @@
'''
time_xml = ([xml % (day, amount) for day, amount in month.iteritems()])
- # Computing the employee
- cr.execute("select name from resource_resource where id=%s", (id,))
- emp = cr.fetchone()[0]
-
# Computing the xml
xml = '''
<employee id="%d" name="%s">
@@ -94,8 +90,9 @@
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
for id in data['form']['employee_ids']:
user = emp_obj.browse(cr, uid, id).user_id.id
+ empl_name = emp_obj.browse(cr, uid, id).name
if user:
- emp_xml += emp_create_xml(cr, id, som, eom)
+ emp_xml += emp_create_xml(cr, user, som, eom, empl_name)
# Computing the xml
#Without this, report don't show non-ascii characters (TO CHECK)
date_xml = '\n'.join(date_xml)
Follow ups