コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
17734 ビュー

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)

アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
2
2月 22
5003
1
8月 15
2945
1
4月 15
22469
2
3月 15
5239
1
3月 15
4076