[MERGE] lp881356
[odoo/odoo.git] / addons / document / directory_report.py
index 657fd39..202725a 100644 (file)
@@ -6,16 +6,16 @@
 #    $Id$
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    it under the terms of the GNU Affero General Public License as published by
 #    the Free Software Foundation, either version 3 of the License, or
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -26,7 +26,7 @@ class ir_action_report_xml(osv.osv):
     _name="ir.actions.report.xml"
     _inherit ="ir.actions.report.xml"
 
-    def _model_get(self, cr, uid, ids, name, arg, context):
+    def _model_get(self, cr, uid, ids, name, arg, context=None):
         res = {}
         model_pool = self.pool.get('ir.model')
         for data in self.read(cr, uid, ids, ['model']):
@@ -39,11 +39,15 @@ class ir_action_report_xml(osv.osv):
                     res[data.get('id')] = False
         return res
 
-    def _model_search(self, cr, uid, obj, name, args, context={}):
+    def _model_search(self, cr, uid, obj, name, args, context=None):
         if not len(args):
             return []
+        assert len(args) == 1 and args[0][1] == '=', 'expression is not what we expect: %r' % args
         model_id= args[0][2]
         if not model_id:
+            # a deviation from standard behavior: when searching model_id = False
+            # we return *all* reports, not just ones with empty model.
+            # One reason is that 'model' is a required field so far
             return []
         model = self.pool.get('ir.model').read(cr, uid, [model_id])[0]['model']
         report_id = self.search(cr, uid, [('model','=',model)])
@@ -52,7 +56,9 @@ class ir_action_report_xml(osv.osv):
         return [('id','in',report_id)]
 
     _columns={
-        'model_id' : fields.function(_model_get, fnct_search=_model_search, method=True, string='Model Id'),
+        'model_id' : fields.function(_model_get, fnct_search=_model_search, string='Model Id'),
     }
 
 ir_action_report_xml()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: