콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
4382 화면

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
4256
2
10월 18
3120
0
3월 15
3527
1
3월 15
5469
0
3월 15
3181