Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
16395 Lượt xem

When iam running code iam getting  error like this 'SQL query parameters should be a tuple, list or dict'

This is my code

@api.multi

def issue_material(self):

jobsheet_no = self.jobsheet_no

self.ensure_one()

result = []

self.env.cr.execute("""SELECT move.name as product,move.product_uom_qty as quantity,pick.name as                 delivered from stock_move move,stock_picking pick where move.picking_id = pick.id and                 move.state = 'done' and move.location_id!=9 and pick.jobsheet_no=%s""",(jobsheet_no.id))

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Shayar,

Inspite of COMMA ',' try using '%'

pick.jobsheet_no=%s"""%(jobsheet_no.id)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

hello shayar,

try jobsheet_no.ids  instead of jobsheet_no.id

self.env.cr.execute("""SELECT move.name as product,move.product_uom_qty as quantity,pick.name as                 delivered from stock_move move,stock_picking pick where move.picking_id = pick.id and                 move.state = 'done' and move.location_id!=9 and pick.jobsheet_no=%s""",(jobsheet_no.ids))

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Use this one

self.env.cr.execute("""SELECT move.name as product,move.product_uom_qty as quantity,pick.name as                 
delivered    from stock_move move,stock_picking pick where move.picking_id = pick.id
and                 move.state = 'done'
and move.location_id!=9
and pick.jobsheet_no="""+str(jobsheet_no.id)+"""""")


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

in sql query you are using %s parameter

so you have to pass arguments using %s only

but here end of the query you are passing , operator instead of %s


 

Ảnh đại diện
Huỷ bỏ