[IMP]:MRP module sql queries to parameterized query
bzr revid: nch@tinyerp.com-20091124131045-cl53el8bke3o1py2
This commit is contained in:
parent
c214c029d4
commit
c13ca999d8
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero 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/>.
|
# 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):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 500
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
@ -363,7 +363,7 @@ class mrp_production(osv.osv):
|
||||||
parent_move_line=get_parent_move(production['move_prod_id'][0])
|
parent_move_line=get_parent_move(production['move_prod_id'][0])
|
||||||
if parent_move_line:
|
if parent_move_line:
|
||||||
move = move_obj.browse(cr,uid,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
|
#as may be mrp can be installed without sale module
|
||||||
if field_name=='name':
|
if field_name=='name':
|
||||||
res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.name or False
|
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):
|
class mrp_procurement(osv.osv):
|
||||||
_name = "mrp.procurement"
|
_name = "mrp.procurement"
|
||||||
_description = "Procurement"
|
_description = "Procurement"
|
||||||
_order = 'priority,date_planned'
|
_order = 'priority,date_planned'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'origin': fields.char('Origin', size=64,
|
'origin': fields.char('Origin', size=64,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||||
#
|
#
|
||||||
|
@ -15,11 +15,11 @@
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero 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/>.
|
# 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 report.interface import report_int
|
||||||
from pychart import *
|
from pychart import *
|
||||||
from mx.DateTime import *
|
from mx.DateTime import *
|
||||||
|
@ -42,7 +42,7 @@ class external_pdf(render):
|
||||||
render.__init__(self)
|
render.__init__(self)
|
||||||
self.pdf = pdf
|
self.pdf = pdf
|
||||||
self.output_type='pdf'
|
self.output_type='pdf'
|
||||||
|
|
||||||
def _render(self):
|
def _render(self):
|
||||||
return self.pdf
|
return self.pdf
|
||||||
|
|
||||||
|
@ -98,14 +98,13 @@ class report_custom(report_int):
|
||||||
def create(self, cr, uid, ids, datas, context={}):
|
def create(self, cr, uid, ids, datas, context={}):
|
||||||
assert len(ids), 'You should provide some ids!'
|
assert len(ids), 'You should provide some ids!'
|
||||||
colors = choice_colors(len(ids))
|
colors = choice_colors(len(ids))
|
||||||
ids_str = ','.join(map(str, ids))
|
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\
|
"SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\
|
||||||
"FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\
|
"FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\
|
||||||
"WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\
|
"WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\
|
||||||
"AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\
|
"AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\
|
||||||
"AND mrp_production.state NOT IN ('cancel','done') "\
|
"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()
|
res = cr.dictfetchone()
|
||||||
if not res['stop']:
|
if not res['stop']:
|
||||||
res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
@ -136,8 +135,8 @@ class report_custom(report_int):
|
||||||
# select workcenters
|
# select workcenters
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT id, name FROM mrp_workcenter " \
|
"SELECT id, name FROM mrp_workcenter " \
|
||||||
"WHERE id in (%s) "\
|
"WHERE id=ANY(%s)" \
|
||||||
"ORDER BY mrp_workcenter.id" % ids_str)
|
"ORDER BY mrp_workcenter.id" ,(ids,))
|
||||||
workcenters = cr.dictfetchall()
|
workcenters = cr.dictfetchall()
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
@ -161,7 +160,7 @@ class report_custom(report_int):
|
||||||
vals.append(res[0]['cycles'] or 0.0)
|
vals.append(res[0]['cycles'] or 0.0)
|
||||||
else:
|
else:
|
||||||
vals.append(res[0]['hours'] or 0.0)
|
vals.append(res[0]['hours'] or 0.0)
|
||||||
|
|
||||||
toto = [dates[date]['name']]
|
toto = [dates[date]['name']]
|
||||||
for val in vals:
|
for val in vals:
|
||||||
toto.append(val)
|
toto.append(val)
|
||||||
|
@ -184,7 +183,7 @@ class report_custom(report_int):
|
||||||
self.obj.render()
|
self.obj.render()
|
||||||
pdf_string.close()
|
pdf_string.close()
|
||||||
return (self.obj.pdf, 'pdf')
|
return (self.obj.pdf, 'pdf')
|
||||||
|
|
||||||
def _empty_graph(self, date):
|
def _empty_graph(self, date):
|
||||||
data = [[date, 0]]
|
data = [[date, 0]]
|
||||||
ar = area.T(x_coord = category_coord.T(data, 0), y_range = (0, None),
|
ar = area.T(x_coord = category_coord.T(data, 0), y_range = (0, None),
|
||||||
|
|
Loading…
Reference in New Issue