This question has been flagged
2 Replies
4555 Views

i want to check the value of jobsheet field with database. When i run my code it gives syntax errors

self._cr.execute("""


CREATE OR REPLACE VIEW jobsheet_overview AS (

SELECT

row_number() over (ORDER BY move.name) AS id,

move.name as product,

move.product_uom_qty as quantity,

pick.id as picking_id

from stock_move move,stock_picking pick where move.picking_id = pick.id and pick.jobsheet_no=%s)""",(self.jobsheet))

it says "%s" syntax is not correct 

Avatar
Discard
Best Answer

Hi Mike

in that last you should pass value as %(self.jobsheet) below i corrected

self._cr.execute("""


CREATE OR REPLACE VIEW jobsheet_overview AS (

SELECT

row_number() over (ORDER BY move.name) AS id,

move.name as product,

move.product_uom_qty as quantity,

pick.id as picking_id

from stock_move move,stock_picking pick where move.picking_id = pick.id and pick.jobsheet_no=%s)""" %(self.jobsheet))

Avatar
Discard
Best Answer

Try this one

self._cr.execute("""
CREATE OR REPLACE VIEW jobsheet_overview AS (
SELECT
row_number() over (ORDER BY move.name) AS id,
move.name as product,
move.product_uom_qty as quantity,
pick.id as picking_id
from stock_move move,stock_picking pick where move.picking_id = pick.id and pick.jobsheet_no="""+str(self.jobsheet)+""")
"""


Avatar
Discard