diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py index 28228b4ab58..663df95047b 100644 --- a/addons/base_report_creator/base_report_creator.py +++ b/addons/base_report_creator/base_report_creator.py @@ -193,16 +193,17 @@ class report_creator(osv.osv): if context is None: context = {} data = context.get('report_id', False) + res = super(report_creator, self).read(cr, user, ids, fields, context, load) if (not context) or 'report_id' not in context: - return super(report_creator, self).read(cr, user, ids, fields, context, load) + return res ctx = context or {} wp = '' - if data: + for data in res: + if not data.get('sql_query'): + return res if self.model_set_id: wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))] - report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) - sql_query = report[data] - cr.execute(sql_query) + cr.execute(data['sql_query']) res = cr.dictfetchall() fields_get = self.fields_get(cr, user, None, context) for r in res: @@ -216,7 +217,7 @@ class report_creator(osv.osv): related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0] r[k] = related_name - return res + return res def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ @@ -253,9 +254,8 @@ class report_creator(osv.osv): newargs += [("count(*) " + a[1] +" " + str(a[2]))] ctx = context or {} ctx['getid'] = True - report = self._sql_query_get(cr, user, [context_id], 'sql_query', None, ctx, where_plus = newargs, limit=limit, offset=offset) - query = report[context_id] - cr.execute(query, newargs2) + sql_query = report.sql_query + cr.execute(sql_query, newargs2) result = cr.fetchall() return map(lambda x: x[0], result) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index daf00e04006..e0e65d3b640 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -730,12 +730,15 @@ - + + - + help="Manufacturing Orders which are ready to start production."/> tree,form,calendar,graph,gantt - {'search_default_current':1} + {'search_default_ready':1} Manufacturing Orders are usually proposed automatically by OpenERP based on the bill of materials and the procurement rules, but you can also create manufacturing orders manually. OpenERP will handle the consumation of the raw materials (stock decrease) and the production of the finished products (stock increase) when the order is processed. diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index f30d65d8f28..cd197222eaa 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -99,7 +99,10 @@ class purchase_report(osv.osv): extract(epoch from age(l.date_planned,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass, count(*) as nbr, (l.price_unit*l.product_qty*u.factor)::decimal(16,2) as price_total, - avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation, + avg(case when t.standard_price <= 0 then (l.price_unit*l.product_qty*u.factor) + else + (100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor)) + end) as negociation, sum(t.standard_price*l.product_qty*u.factor)::decimal(16,2) as price_standard, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s