Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

Grant portal access automatically when contact is created

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
automatedportal-userodoo.shv12
4 Trả lời
12070 Lượt xem
Ảnh đại diện
Chris Leray

HI, 


I am trying to create an automated action in order to automatically grant portal access to a new contact. 

As right now if you create a new contact from the POS they don't have access to the website so they have to create a new account and then contacts are duplicated.

Maybe there is better to do it than automated action?

thanks, 

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

Hi Chris:

Using an automated action is the simplest and most elegant way of doing this.

EDIT:

Create an automated action on the Contact (res.partner) model with a Trigger Condition of On Creation and Action To Do of Execute Python Code

Put the following code in the Python Code field:

# Ensure an email address has been entered so that it can be used for the login
if not record.email:
    raise Warning("Please enter an email address.")

x_group_portal_user = env.ref('base.group_portal')
env['res.users'].create([{'name': record.name,
                          'login': record.email,
                          'partner_id': record.id,
                          'company_id': env.company.id, 
                          'groups_id': [(6, 0, [x_group_portal_user.id])],
                          }],)

1
Ảnh đại diện
Huỷ bỏ
Chris Leray
Tác giả

thanks for your message. I have tried to create this automated action but it still does now work. I am not sure about the loving there and python code I should add ?

any chance u can help?

thanks

Paresh Wagh

Hi Chris: I have edited my post and added the details.

Chris Leray
Tác giả

awesome, thanks a lot, it works perfectly. I just add to remove the 'company_id': env.company.id,

but all good.

Chris Leray
Tác giả

Actually I realized that with this script it also publish the contact on the website which I don't want to.

I want to grant them the access but don't want to publish the contact on the website if that make sense.

I had a look at my group and it looks like my grant port is id = 9 and not 6. I changed it to 9 but then it does now work.

I think this is not the same group, what am i missing here?

sorry, thanks a lot

Paresh Wagh

Hi Chris:

The (6,0,...) part is the syntax for populating one2many/many2many fields. The "6" indicates that the existing groups assigned to this user need to be removed and replaced with the portal user group. If you need more groups to be assigned to the user, you will need to add their ref ids to the array of group ids on the right.

Here's a link to the documentation (you will have to scroll down a bit to the one2many.many2many part):

https://www.odoo.com/documentation/13.0/reference/orm.html#create-update

Regarding the question about the Contact getting published to the website, when I try this out in my environment, the Contact is not getting automatically published. There must be something else in your environment that is triggering off the publish.

You can try to get around this by adding the following line at the end of the code (after the create).

record['is_published'] = False

This will reset the published flag to False even if it gets set to True somewhere else.

NOTE: You may want to use this as a last resort only if you cannot find what is automatically triggering the publish.

Chris Leray
Tác giả

ok I see, this is really helpful thanks a lot. I will try to understand where is this coming from

thanks ,

Cherry Rose Sanchez

hi can you add a condition, wherein portal access will be granted only if the contact has that information. otherwise, it will skip. example: a custom field "portal_user" is true before granting portal access upon creation? and does it work if odoo bot created the contact via website?

Ảnh đại diện
Luke Austin
Câu trả lời hay nhất

I'm using this ina  slightly different context - ie on sales order confirmation, so I need to check if theuser has already been granted portal access.

I've tried a few things, like:

if not record.partner_id.has_group('base.portal_users'):

Which doesn't work, because it's addressing the partner, not the user but I can't see how to get from record to the user group. How would you add a conditional to exclude existing portal users from this code? 

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

Just do simplify,

In wizard just replace your apply button with following button

<button name="1174" type="action" string="Apply"/>

here name is the id of your server action. 

In server action you can add the code like,

for rec in records:

  for userin rec.user_ids:

    user['in_portal'] = True

 rec.action_apply()

Video : https://youtu.be/Mjr-RpITSC0

0
Ảnh đại diện
Huỷ bỏ
Diego Riera Diaz

Hi Muhammad,

I am new to Odoo dev. Looking at your video and in V15. Did you create a new server action or updated an existing one ?

Thanks you !

Diego

Ảnh đại diện
Chris TRINGHAM
Câu trả lời hay nhất

Paresh's solution works, and will automatically create portal access for all contacts, so you might want to add "Apply On": Customer Rank is set

 [["customer_rank","!=",False]]
One other suggestion.  If you create customers through the normal Odoo user interface (and not POS), there is an action to "add portal access" (you can do this for multiple customers from the list view or for individual customers using the Form View).


This image has an empty alt attribute; its file name is grant-portal-access-list-view.jpg

This image has an empty alt attribute; its file name is grant-portal-access.jpg
0
Ảnh đại diện
Huỷ bỏ
Chris Leray
Tác giả

great thanks a lot for your help:) all good

Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Add a Mailing contact automatically to a mailing list Đã xử lý
python automated mailing odoo.sh v12
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
12
thg 4 24
14508
Automated action with python expression Đã xử lý
action python automated odoo.sh v12
Ảnh đại diện
Ảnh đại diện
6
thg 3 24
10690
How to code Automated Action to update a ManytoOne custom field to match source field?
automated v12
Ảnh đại diện
Ảnh đại diện
2
thg 7 19
6632
[v12] adding field to res_partner breaks odoo.sh instance Đã xử lý
odoo.sh v12 upgrad
Ảnh đại diện
Ảnh đại diện
3
thg 8 21
4550
How to access sudo on Odoo.sh? v12
sudouser odoo.sh v12
Ảnh đại diện
Ảnh đại diện
3
thg 8 19
10481
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now