Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how can I write a def _getdaysbetween fot timedelta between 2 date in a module?

By
nasim
on 1/21/16, 1:30 AM 347 views

hi

how can I write a def _getdaysbetween fot timedelta between 2 date in a module?

my .py code (for a webkit report) is:

def _getdaysbetween(self, date_start, write_date):

sql = "SELECT write_date - date_start from purchase_requisition as pr

where pr.date_start = \'%s\' AND pr.write_date = \'%s\' " %(date_start, write_date)

self.cr.execute(sql)

return self.cr.fetchall()

but when I want to create a report from purchase requisition, this error show:

SyntaxError: EOL while scanning string literal

I don't know what is problem?

Thanks for your help

0

Yenthe

--Yenthe--
6706
| 7 7 8
Turnhout, Belgium
--Yenthe--

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

Yenthe
On 1/21/16, 1:51 AM

Hi Nasim,

When you look at your SQL query you can see the following:

sql = "SELECT write_date - date_start from purchase_requisition as pr

Your SyntaxError is literally telling what is wrong, you're missing a ' or " in your script and it is right at the end of your SQL statement. You open up the sql statement with " but never close it. This should fix it:

sql = "SELECT write_date - date_start from purchase_requisition as pr"

Yenthe

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/21/16, 1:30 AM
Seen: 347 times
Last updated: 1/21/16, 4:12 AM