Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How can i make the some fields to readonly after it changes its status to next stage?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
server_action python
1 Odpowiedz
3579 Widoki
Awatar
Anton

I created a new customized model in odoo 17 using studio, it's a form. There's this pipeline stages. (New request, For Approval, On progress, and Done).

I put a button on it. And this button called, "submit". I created the button's action in Technical>Server Actions>Execute Code. Now, i want this button to function as, when the normal user filled up the form, then clicked the submit button, the form will change to next stage (From 'new request' to 'for approval' stage). And the some fields in the form must change to not fillable field or readonly. (Only user who have a administrative rights can edit it.)

Here's the execute code that i tried..

`

for record in records:
    values = {
        'x_studio_stage_id': 2,
    }   
    record.write(values)

field_names = ['x_name', 'x_studio_position', 'x_studio_department', 'x_studio_read', 'x_studio_write', 'x_studio_create', 'x_studio_delete', 'x_studio_reason_and_justification']  # Replace with your field names

fields = env['ir.model.fields'].search([('model', '=', 'x_access_request'), ('name', 'in', field_names)])

group_id = env.ref('__export__.res_groups_183_e7aae201').id 
access = env['ir.model.access'].search([('model_id', '=', model_id), ('group_id', '=', group_id)])
if not access:
    access = env['ir.model.access'].create({
        'name': 'Access Rights for Group',
        'model_id': model_id,
        'group_id': group_id,
    })

for field in fields:
    access.write({
        'perm_read': [(4, field.id)],  # Add readonly permission
        'perm_write': [(3, field.id)],  # Remove write permission
    })


But it's telling the user to have a "administration/access rights" permission.

0
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

Hi,


In your code, you're trying to modify the access rights for a group, which requires administrative privileges. Normal users typically don't have the necessary permissions to perform such operations.

Create a new group in Odoo called "Request Submitters" and assign the necessary permissions to this group for reading and writing the fields you want to make read-only after submission.

In your custom model's form view, add the groups attribute to the fields you want to make read-only after submission. For example:

XML:

<field name="x_name" groups="base.group_user,your_module.group_request_submitters"/>
<field name="x_studio_position" groups="base.group_user,your_module.group_request_submitters"/>


In your server action code, update the stage_id field to move the record to the next stage when the "Submit" button is clicked:

Python:

for record in records:
    record.x_studio_stage_id = 2  # Replace 2 with the appropriate stage ID


Hope it helps.


0
Awatar
Odrzuć
Anton
Autor

I tried to follow your instructions clearly.

Here's what i did:
Settings>Groups>New.

Application:
Name: Request Submitters
Share Group: (Uncheck)
Users Tab: TEST User
Inherited Tab:
Menus Tab:
Views Tab:
Access Rights Tab: x_access_request - READ/WRITE/CREATE
Record Rules Tab:
Notes: Tab:

Now, i dont know which one to edit. Because the studio created 2 form "Default form view for x_access_request" and "Odoo Studio: Default form view for x_access_request customization". But i did manage to identify, which is "Odoo Studio: Default form view for x_access_request customization". I added the "groups="base.group_user,your_module.group_request_submitters"/>"

But, it doesn't work.

Anton
Autor

Didn't actually work.

The x_name was in..

<data>
<xpath expr="//field[@name='x_name']" position="attributes">
<attribute name="force_save">0</attribute>
<attribute name="groups">base.group_user</attribute>
<attribute name="placeholder">What system access to request?</attribute>
<attribute name="string">Request</attribute>
</xpath>

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Failure Odoo13.service Main PID:1064
server_action python
Awatar
Awatar
1
kwi 20
6411
How to delete the supplier info from a tree list of products?V8 Rozwiązane
v8 saas supplier server_action python
Awatar
Awatar
Awatar
5
lut 16
4942
How to get multiple values with Python expression in a Server Action
python values expression serveraction server_action python
Awatar
Awatar
1
gru 22
9054
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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