[FIX] hr_timesheet_invoice: warning in report generation
authorAntonio Esposito <espo-tony@users.noreply.github.com>
Mon, 27 Oct 2014 12:00:18 +0000 (13:00 +0100)
committerMartin Trigaux <mat@odoo.com>
Tue, 28 Oct 2014 10:00:07 +0000 (11:00 +0100)
When generating the report 'Timesheet Profit', got a warning "The domain term '('user_id', '=', [...])' should use the 'in' or 'not in' operator."
This warning is due to the use of the '=' operator to compare the field 'user_id' while the reports sends a list of ids.
Fallback to still accept a single id in case of customised reports.

addons/hr_timesheet_invoice/report/account_analytic_profit.py

index 57fd06b..dfdce39 100644 (file)
@@ -37,13 +37,15 @@ class account_analytic_profit(report_sxw.rml_parse):
         return user_obj.browse(self.cr, self.uid, ids)
 
     def _journal_ids(self, form, user_id):
+        if isinstance(user_id, (int, long)):
+            user_id = [user_id]
         line_obj=pooler.get_pool(self.cr.dbname).get('account.analytic.line')
         journal_obj=pooler.get_pool(self.cr.dbname).get('account.analytic.journal')
         line_ids=line_obj.search(self.cr, self.uid, [
             ('date', '>=', form['date_from']),
             ('date', '<=', form['date_to']),
             ('journal_id', 'in', form['journal_ids'][0][2]),
-            ('user_id', '=', user_id),
+            ('user_id', 'in', user_id),
             ])
         ids=list(set([b.journal_id.id for b in line_obj.browse(self.cr, self.uid, line_ids)]))
         return journal_obj.browse(self.cr, self.uid, ids)