[IMP]:MRP module sql queries to parameterized query

bzr revid: nch@tinyerp.com-20091124131045-cl53el8bke3o1py2
This commit is contained in:
nch@tinyerp.com 2009-11-24 18:40:45 +05:30
parent c214c029d4
commit c13ca999d8
2 changed files with 15 additions and 16 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -215,9 +215,9 @@ class mrp_bom(osv.osv):
]
def _check_recursion(self, cr, uid, ids):
level = 500
level = 100
while len(ids):
cr.execute('select distinct bom_id from mrp_bom where id in ('+','.join(map(str, ids))+')')
cr.execute('select distinct bom_id from mrp_bom where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
@ -363,7 +363,7 @@ class mrp_production(osv.osv):
parent_move_line=get_parent_move(production['move_prod_id'][0])
if parent_move_line:
move = move_obj.browse(cr,uid,parent_move_line)
#TODO: fix me sale module can not be used here,
#TODO: fix me sale module can not be used here,
#as may be mrp can be installed without sale module
if field_name=='name':
res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.name or False
@ -782,7 +782,7 @@ mrp_production_product_line()
class mrp_procurement(osv.osv):
_name = "mrp.procurement"
_description = "Procurement"
_order = 'priority,date_planned'
_order = 'priority,date_planned'
_columns = {
'name': fields.char('Name', size=64, required=True),
'origin': fields.char('Origin', size=64,

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -15,11 +15,11 @@
# GNU Affero General Public License for more details.
#
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from report.render import render
from report.render import render
from report.interface import report_int
from pychart import *
from mx.DateTime import *
@ -42,7 +42,7 @@ class external_pdf(render):
render.__init__(self)
self.pdf = pdf
self.output_type='pdf'
def _render(self):
return self.pdf
@ -98,14 +98,13 @@ class report_custom(report_int):
def create(self, cr, uid, ids, datas, context={}):
assert len(ids), 'You should provide some ids!'
colors = choice_colors(len(ids))
ids_str = ','.join(map(str, ids))
cr.execute(
"SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\
"FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\
"WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\
"AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\
"AND mrp_production.state NOT IN ('cancel','done') "\
"AND mrp_workcenter.id IN (%s)" % ids_str)
"AND mrp_workcenter.id =ANY(%s)",(ids,))
res = cr.dictfetchone()
if not res['stop']:
res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S')
@ -136,8 +135,8 @@ class report_custom(report_int):
# select workcenters
cr.execute(
"SELECT id, name FROM mrp_workcenter " \
"WHERE id in (%s) "\
"ORDER BY mrp_workcenter.id" % ids_str)
"WHERE id=ANY(%s)" \
"ORDER BY mrp_workcenter.id" ,(ids,))
workcenters = cr.dictfetchall()
data = []
@ -161,7 +160,7 @@ class report_custom(report_int):
vals.append(res[0]['cycles'] or 0.0)
else:
vals.append(res[0]['hours'] or 0.0)
toto = [dates[date]['name']]
for val in vals:
toto.append(val)
@ -184,7 +183,7 @@ class report_custom(report_int):
self.obj.render()
pdf_string.close()
return (self.obj.pdf, 'pdf')
def _empty_graph(self, date):
data = [[date, 0]]
ar = area.T(x_coord = category_coord.T(data, 0), y_range = (0, None),