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

I want to create using sql command because if i am using self.create that was take a long time to get a result.

@api.multi

def action_create_history(self):

    for rec in self :

        history_obj = self.env['history.table']

        hd  = []

        hd['partner_id'] = rec.id

        hd['old_state']  = rec.state

        hd['new_state'] = 'open'

        hd['partner_reg_id']  = rec.partner_no

        hd['state']   = 'complete'
        

        history = history_obj.create(hd)

        partner.write({'history_id' : history.id})

i want change it into sql please give advice

アバター
破棄
最善の回答

Hi Chaanto,

You can execute queries like following

self._cr.execute('INSERT INTO my_test_table (column1, column2) VALUES (%s, %s)', (value1, value2))

To get the related database table of a model, put underscore instead of dots.

Thanks


iWesabe

アバター
破棄
著作者

Hi Global Creative Concepts Tech Co Ltd

For basic command like that i know but when i insert how about xml id, database id, etc.

is that insert automatically if not what paramater that should i put on query ?

関連投稿 返信 ビュー 活動
1
2月 21
4341
2
10月 18
3144
0
3月 15
3565
1
3月 15
5540
0
3月 15
3212