Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8141 Lượt xem

Hi I want to get the partner_id of a user for doing something like:

<act_window id="action_my_module_received_reviews" name="Received Reviews" res_model="my_module.review" domain="[('reviewer_id', '=', uid.partner_id)]"/> 

How can I do that?

EDIT: Solution - for simplicity I just reference the user id in my model directly instead of the partner_id

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Sorry but you can't. Actually to do this you need to override the search on the model. Can be something like this:

def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
#this could have a check for this add domain based on a context value
partner_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id
args.append(('reviewer_id','=',partner_id.id))
return super(my_module_review, self).search(cr, uid, args, offset, limit, order, context, count)
Ảnh đại diện
Huỷ bỏ

You are correct. But could you provide a more detailed answer?

I edit my answer for an example of how to do it

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 11 16
7008
3
thg 4 20
6313
0
thg 7 15
5572
0
thg 10 23
1857
1
thg 9 21
1859