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

Hello,

This question is similar to one posted some years ago: 
("Grant portal access automatically when contact is created", I can't post the link)
... but I'm using Odoo Studio.

I would like people to sign up for free to my website and then give them some functionality.  I've heard that the way to go is to create a portal user from the contact that is created when someone signs up.  

I'm looking at actions but it feels like the Studio interface doesn't allow me to dig down deep enough to select the filds I was to copy.  Is this possible using Studio?  I have the entreprise subscription.


Thanks, much obliged.                                                                                               

Stephen                                                                                                                                                                                                                                     

아바타
취소

This is the original question, and the answer there seems like the simplest way to do it. Studio isn't going to provide any useful extra functionality for this requirement.

https://www.odoo.com/forum/help-1/grant-portal-access-automatically-when-contact-is-created-168660

작성자 베스트 답변

This worked for me:
For someone who signs up, providing an email address and a password:

First, see if there's a partner with that email address:

partner = request.env['res.partner'].sudo().search([('email', '=', login)], limit=1)

If there isn't then create a partner:

partner = request.env['res.partner'].sudo().create({'name': login, 'email': login})


then create the user linked to the partner record:

             # Create the new portal user linked to the partner

   newUser = request.env['res.users'].sudo().create({
​ 'name': login,
    'login': login,
    'partner_id': partner.id,
    'password': password,
    'groups_id': [(6, 0, [portal_group.id])]
  })

                

아바타
취소
베스트 답변

Hi,

Steps:

Go to Settings → Technical → Automated Actions.

    Create a new automated action:

    Model: res.partner (Contacts)

    Trigger: On Creation

    Action: Create a Record

    You can configure Studio to create a new res.users record.

    Set the partner_id to the created contact.

    Set groups_id to include the Portal group.


If action execute code

Code:

if not record.user_ids:

    user = env['res.users'].create({

        'name': record.name,

        'login': record.email,

        'partner_id': record.id,

        'groups_id': [(4, env.ref('base.group_portal').id)],

    })


Hope it helps.

아바타
취소
관련 게시물 답글 화면 활동
1
12월 23
5938
1
5월 25
1889
1
3월 25
1930
MERGING CONTACTS 해결 완료
1
2월 25
7272
Use of external id 해결 완료
2
2월 25
4000