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

I am trying to delete some record from database not the current record, and i got error like this:

 

result = [method(rec, *args, **kwargs) for rec in self] 

return new_api(self, *args, **kwargs)

ValueError: "unlink() takes exactly 1 argument (2 given)" while evaluating

 

and here my code:

class demo_demo(models.Model):

_name = 'demo.demo'

...

@api.multi

def unlink(self):

return super(demo_demo, self).unlink()

 

@api.one

def _delete_from_db(self):

# Search data in database for current model

find_id = self.search([('name', '=', 'demo')]) # result demo.demo(1,)

self.unlink(find_id.id)

Thanks.

 

 

아바타
취소
작성자 베스트 답변

I think i solved it :)

here my solution:

self.search([('name', '=', 'demo')]).unlink()

아바타
취소
베스트 답변

use something like this

self.env["hr.employee"].search([('type','=','permanent')]).unlink()

아바타
취소
베스트 답변

l have apparently less than 8 karma! :-)
... In your code, I get the impression you send the name as a parameter and then look for the id. Why is that!? Why not just send the id as a a parameter? Sending id as parameter makes sense and will always work. I'm looking for a solution deleting records using id as parameter.

아바타
취소
베스트 답변

To delete records with constraint just like account e.t.c 

watch this module: https://youtu.be/4v5P1UdhdxU

아바타
취소
관련 게시물 답글 화면 활동
1
5월 25
551
0
1월 24
1298
2
5월 23
8139
1
2월 22
23176
5
12월 21
16250