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 execute SQL code in openerp server ?

By
ThackerS (ts)
on 8/22/14, 10:13 PM 3,757 views

Hi.
I want to execute the code below :

Select * from res_users;

from a python methode in openerp. My module look like that :

def my_sql_method(self,cr,uid) :

#it is my method which execute my sql code
 

How can i do that ?

NB: I don't want to execute my sql code in postgresql (easy)

3

Remya

--Remya--
5813
| 7 8 8
Thiruvananthapuram, India
--Remya--

Working as an Senior ODOO developer. http://in.linkedin.com/pub/remya-r/69/a23/298

Remya
On 8/23/14, 12:53 AM

A sample code is pasted here. You can refer the below code.

 

def move_line_get(self, cr, uid, invoice_id):
        res = []
        cr.execute('SELECT * FROM account_invoice_tax WHERE invoice_id=%s', (invoice_id,))
        for t in cr.dictfetchall():
            if not t['amount'] \
                    and not t['tax_code_id'] \
                    and not t['tax_amount']:
                continue
            res.append({
                'type':'tax',
                'name':t['name'],
                'price_unit': t['amount'],
                'quantity': 1,
                'price': t['amount'] or 0.0,
                'account_id': t['account_id'],
                'tax_code_id': t['tax_code_id'],
                'tax_amount': t['tax_amount'],
                'account_analytic_id': t['account_analytic_id'],
            })
        return res

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: 8/22/14, 10:13 PM
Seen: 3757 times
Last updated: 3/16/15, 8:10 AM