تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7863 أدوات العرض

I am trying to work on a query in openerp 6.1, but it gives an error:

ProgrammingError: operator does not exist: character varying = integer LINE 1: SELECT debit,credit FROM account_move_line WHERE ref = 434 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

And my query:

move_obj = self.pool.get('account.move.line')
cr.execute("SELECT debit,credit FROM account_move_line WHERE  ref = %s",(move_id,))

Please help i tried looking at the typecast methods tried few but it always have some error or probably the module to be imported was missing. Its damn too urgent!

الصورة الرمزية
إهمال
أفضل إجابة

The issue is that ref expects a string. In SQL, strings need to be surrounded by single quotes ( ' )

So the following (add a ' before and after %s) should do the trick:

move_obj = self.pool.get('account.move.line')
cr.execute("SELECT debit,credit FROM account_move_line WHERE  ref = '%s'",(move_id,))

You do not get string errors, becausew you start and end with a double quote ( " ), which does NOT end with a single quote ( ' ).

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أبريل 15
4605
0
فبراير 25
1586
2
يناير 25
8216
0
يوليو 24
1267
2
يناير 24
10138