Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Grant portal access automatically when contact is created

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
automatedportal-userodoo.shv12
4 Răspunsuri
12071 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Paresh Wagh
Cel mai bun răspuns

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
Imagine profil
Abandonează
Chris Leray
Autor

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
Autor

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

but all good.

Chris Leray
Autor

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
Autor

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?

Imagine profil
Luke Austin
Cel mai bun răspuns

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
Imagine profil
Abandonează
Imagine profil
MUHAMMAD Imran
Cel mai bun răspuns

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
Imagine profil
Abandonează
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

Imagine profil
Chris TRINGHAM
Cel mai bun răspuns

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
Imagine profil
Abandonează
Chris Leray
Autor

great thanks a lot for your help:) all good

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Add a Mailing contact automatically to a mailing list Rezolvat
python automated mailing odoo.sh v12
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
12
apr. 24
14509
Automated action with python expression Rezolvat
action python automated odoo.sh v12
Imagine profil
Imagine profil
6
mar. 24
10691
How to code Automated Action to update a ManytoOne custom field to match source field?
automated v12
Imagine profil
Imagine profil
2
iul. 19
6632
[v12] adding field to res_partner breaks odoo.sh instance Rezolvat
odoo.sh v12 upgrad
Imagine profil
Imagine profil
3
aug. 21
4550
How to access sudo on Odoo.sh? v12
sudouser odoo.sh v12
Imagine profil
Imagine profil
3
aug. 19
10481
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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