Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7352 มุมมอง

I have made a qweb report for res.partner that should list all the projects for that customer. But i don't know how to take the id for the current res.partner so i can search the database. I want to do something like the following code(where self.id is the id for the current partner):

data=self.env['project.project'].search([('partner_id', '=', self.id)])
อวตาร
ละทิ้ง
ผู้เขียน

It doesn't work as i want. It returns the id of the logged user in contacts. I want to return the current open contact. For example if i call the function from the contact menu of Delta PC, i want the id of the contact Delta PC.Sorry that i am writhing this here bu i can't write comments.

partner = self.env['res.users'].browse(self.env.uid).partner_id
data = self.env['project.project'].search([('partner_id', '=', partner.id)])

Hope this helps you !

คำตอบที่ดีที่สุด

Hello, you can pass this on the " context " , of try to create a many2one field :), just add on the xml context = ''parnter_id'': partner_id

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
มี.ค. 20
17547
3
เม.ย. 22
16966
1
เม.ย. 22
9516
2
ก.ค. 25
4691
2
ธ.ค. 24
7810