fix pylint warning and errors

This commit is contained in:
Alexandre Fayolle
2018-07-15 12:12:20 +02:00
committed by joan
parent d044dbb12c
commit 32bfd8326a

View File

@@ -28,20 +28,20 @@ class Inventory(models.Model):
products_to_filter = self.env['product.product'] products_to_filter = self.env['product.product']
if self.company_id.id: if self.company_id.id:
domain += ' and company_id = %s' domain += ' AND company_id = %s'
args += (self.company_id.id,) args += (self.company_id.id,)
if self.partner_id: if self.partner_id:
domain += ' and owner_id = %s' domain += ' AND owner_id = %s'
args += (self.partner_id.id,) args += (self.partner_id.id,)
if self.lot_id: if self.lot_id:
domain += ' and lot_id = %s' domain += ' AND lot_id = %s'
args += (self.lot_id.id,) args += (self.lot_id.id,)
if self.product_id: if self.product_id:
domain += ' and product_id = %s' domain += ' AND product_id = %s'
args += (self.product_id.id,) args += (self.product_id.id,)
products_to_filter |= self.product_id products_to_filter |= self.product_id
if self.package_id: if self.package_id:
domain += ' and package_id = %s' domain += ' AND package_id = %s'
args += (self.package_id.id,) args += (self.package_id.id,)
if self.category_id: if self.category_id:
categ_products = product_obj.search( categ_products = product_obj.search(
@@ -50,13 +50,16 @@ class Inventory(models.Model):
args += (categ_products.ids,) args += (categ_products.ids,)
products_to_filter |= categ_products products_to_filter |= categ_products
self.env.cr.execute(""" # disable error about SQL injection as the code here is generating
SELECT product_id, sum(qty) as product_qty, location_id, lot_id # a vulnerability
as prod_lot_id, package_id, owner_id as partner_id # pylint: disable = E8103
FROM stock_quant self.env.cr.execute(
WHERE %s "SELECT product_id, SUM(qty) AS product_qty, location_id, "
GROUP BY product_id, location_id, lot_id, package_id, " lot_id AS prod_lot_id, package_id, owner_id AS partner_id "
partner_id """ % domain, args) "FROM stock_quant "
"WHERE " + domain + " " +
"GROUP BY product_id, location_id, lot_id, package_id, "
"partner_id """, args)
for product_data in self.env.cr.dictfetchall(): for product_data in self.env.cr.dictfetchall():
for void_field in [item[0] for item in product_data.items() if for void_field in [item[0] for item in product_data.items() if