[MERGE] forward port of branch saas-4 up to revid 9410 chs@openerp.com-20140507164207...
authorChristophe Simonis <chs@openerp.com>
Wed, 7 May 2014 17:01:12 +0000 (19:01 +0200)
committerChristophe Simonis <chs@openerp.com>
Wed, 7 May 2014 17:01:12 +0000 (19:01 +0200)
bzr revid: chs@openerp.com-20140507170112-bjeltv2b0coy60am

16 files changed:
1  2 
addons/account/account_invoice.py
addons/account/account_move_line.py
addons/account_followup/account_followup.py
addons/crm/static/description/index.html
addons/hr_timesheet_sheet/hr_timesheet_sheet.py
addons/mail/mail_mail.py
addons/mail/mail_thread.py
addons/point_of_sale/point_of_sale.py
addons/report/models/report.py
addons/stock/product.py
addons/stock/stock.py
addons/stock/stock_view.xml
addons/website/static/src/js/website.editor.js
addons/website/static/src/js/website.snippets.editor.js
addons/website_forum/controllers/main.py
addons/website_forum/views/website_forum.xml

Simple merge
Simple merge
@@@ -600,23 -626,5 +639,22 @@@ class res_company(osv.osv)
          '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:
@@@ -235,23 -233,18 +235,29 @@@ class mail_mail(osv.Model)
                  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:
Simple merge
Simple merge
@@@ -260,19 -260,25 +260,25 @@@ class Report(osv.Model)
      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',
Simple merge
Simple merge
Simple merge