'timesheet_max_difference': lambda *args: 0.0
}
+class hr_employee(osv.osv):
+ '''
+ Employee
+ '''
+ _inherit = 'hr.employee'
+ _description = 'Employee'
+
+ def _timesheet_count(self, cr, uid, ids, field_name, arg, context=None):
+ Sheet = self.pool['hr_timesheet_sheet.sheet']
+ return {
+ employee_id: Sheet.search_count(cr,uid, [('employee_id', '=', employee_id)], context=context)
+ for employee_id in ids
+ }
+
+ _columns = {
+ 'timesheet_count': fields.function(_timesheet_count, type='integer', string='Timesheets'),
+ }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
email sending process has failed
:return: True
"""
+ if context is None:
+ context = {}
ir_mail_server = self.pool.get('ir.mail_server')
+ ir_attachment = self.pool['ir.attachment']
-
for mail in self.browse(cr, SUPERUSER_ID, ids, context=context):
try:
+ # TDE note: remove me when model_id field is present on mail.message - done here to avoid doing it multiple times in the sub method
+ if mail.model:
+ model_id = self.pool['ir.model'].search(cr, SUPERUSER_ID, [('model', '=', mail.model)], context=context)[0]
+ model = self.pool['ir.model'].browse(cr, SUPERUSER_ID, model_id, context=context)
+ else:
+ model = None
+ if model:
+ context['model_name'] = model.name
- # handle attachments
- attachments = []
- for attach in mail.attachment_ids:
- attachments.append((attach.datas_fname, base64.b64decode(attach.datas)))
++
+ # load attachment binary data with a separate read(), as prefetching all
+ # `datas` (binary field) could bloat the browse cache, triggerring
+ # soft/hard mem limits with temporary data.
+ attachment_ids = [a.id for a in mail.attachment_ids]
+ attachments = [(a['datas_fname'], base64.b64decode(a['datas']))
+ for a in ir_attachment.read(cr, SUPERUSER_ID, attachment_ids,
+ ['datas_fname', 'datas'])]
++
# specific behavior to customize the send email for notified partners
email_list = []
if mail.email_to:
def get_action(self, cr, uid, ids, report_name, data=None, context=None):
"""Return an action of type ir.actions.report.xml.
+ :param ids: Ids of the records to print (if not used, pass an empty list)
:param report_name: Name of the template to generate an action for
"""
- if context is None:
- context = {}
-
+ if ids:
+ if not isinstance(ids, list):
+ ids = [ids]
+ context['active_ids'] = ids
+
report_obj = self.pool['ir.actions.report.xml']
idreport = report_obj.search(cr, uid, [('report_name', '=', report_name)], context=context)
try:
report = report_obj.browse(cr, uid, idreport[0], context=context)
except IndexError:
- raise osv.except_osv(_('Bad Report'), _('This report is not loaded into the database.'))
+ raise osv.except_osv(
+ _('Bad Report Reference'),
+ _('This report is not loaded into the database: %s.' % report_name)
+ )
- action = {
+ return {
'context': context,
'data': data,
'type': 'ir.actions.report.xml',