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

Missing understanding

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
2 Odpowiedzi
914 Widoki
Awatar
Bernhard Marx

Hello. I'm trying to understand "what happens where". As I'm unable to modify/ use the default website from the "Recruitment Application" of odoo I'm trying RPC calls.


So when the (default) form is submitted a email is sent, and from the models a "candiate-model" is created. 

Looking at the hr.applicant ("where the form is going to") the is the candiate id mandatory (relation) but I cant see where the candidate (relation) is created.


Using RPC to hr.applicant using the fields the htpp form is also sending I can't create the entity as a relation to "candidate" is missing. Passing an exisiting id as candidate id I also get an error:

message": "The operation cannot be completed: Error, a partner cannot follow twice the same object.",

            "arguments": [

                "The operation cannot be completed: Error, a partner cannot follow twice the same object."

            ],

0
Awatar
Odrzuć
Bernhard Marx
Autor

Thanks. I understand. But when I pass an exisiting candidate_id I receive:

UniqueViolation: duplicate key value violates unique constraint \"mail_followers_mail_followers_res_partner_res_model_id_uniq\"\nDETAIL:  Key (res_model, res_id, partner_id)=(hr.applicant, 97, 3) already exists.

Christoph Farnleitner

Provide a full example of what you are doing

Awatar
Bernhard Marx
Autor Najlepsza odpowiedź

Sure

I do this RPC call to  http://odooserver:8069/jsonrpc

{

    "jsonrpc": "2.0",

    "method": "call",

    "params": {

        "service": "object",

        "method": "execute",

        "args": [

            "SLTEST",

            "2",

            "123456789",

            "hr.applicant",

            "create",

            {

                "partner_name": "Harry",

                "email_from": "harry@success.com",

                "partner_phone": "1234567",

                "job_id": 2,

                "department_id": 2,

                "linkedin_profile": "abc",

                "candidate_id": 29

            }

        ]

    },

    "id": 33

}


And I receive


{
    "jsonrpc": "2.0",
    "id": 33,
    "error": {
        "code": 200,
        "message": "Odoo Server Error",
        "data": {
            "name": "odoo.exceptions.ValidationError",
            "debug": "Traceback (most recent call last):\n  File \"/usr/lib/python3/dist-packages/odoo/service/model.py\", line 137, in retrying\n    result = func()\n  File \"/usr/lib/python3/dist-packages/odoo/api.py\", line 517, in call_kw\n    result = getattr(recs, name)(*args, **kwargs)\n  File \"<decorator-gen-315>\", line 2, in create\n  File \"/usr/lib/python3/dist-packages/odoo/api.py\", line 479, in _model_create_multi\n    return create(self, [arg])\n  File \"/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py\", line 774, in create\n    records = create.origin(self.with_env(automations.env), vals_list, **kw)\n  File \"<decorator-gen-289>\", line 2, in create\n  File \"/usr/lib/python3/dist-packages/odoo/api.py\", line 480, in _model_create_multi\n    return create(self, arg)\n  File \"/usr/lib/python3/dist-packages/odoo/addons/hr_recruitment/models/hr_applicant.py\", line 323, in create\n    applicants = super().create(vals_list)\n  File \"<decorator-gen-139>\", line 2, in create\n  File \"/usr/lib/python3/dist-packages/odoo/api.py\", line 480, in _model_create_multi\n    return create(self, arg)\n  File \"/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py\", line 271, in create\n    self.env['mail.followers']._insert_followers(\n  File \"/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_followers.py\", line 417, in _insert_followers\n    sudo_self.create([\n  File \"<decorator-gen-146>\", line 2, in create\n  File \"/usr/lib/python3/dist-packages/odoo/api.py\", line 480, in _model_create_multi\n    return create(self, arg)\n  File \"/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_followers.py\", line 54, in create\n    res = super(Followers, self).create(vals_list)\n  File \"<decorator-gen-31>\", line 2, in create\n  File \"/usr/lib/python3/dist-packages/odoo/api.py\", line 480, in _model_create_multi\n    return create(self, arg)\n  File \"/usr/lib/python3/dist-packages/odoo/models.py\", line 4975, in create\n    records = self._create(data_list)\n  File \"/usr/lib/python3/dist-packages/odoo/models.py\", line 5159, in _create\n    cr.execute(SQL(\n  File \"/usr/lib/python3/dist-packages/odoo/sql_db.py\", line 354, in execute\n    res = self._obj.execute(query, params)\npsycopg2.errors.UniqueViolation: duplicate key value violates unique constraint \"mail_followers_mail_followers_res_partner_res_model_id_uniq\"\nDETAIL:  Key (res_model, res_id, partner_id)=(hr.applicant, 98, 3) already exists.\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3/dist-packages/odoo/http.py\", line 2386, in __call__\n    response = request._serve_nodb()\n  File \"/usr/lib/python3/dist-packages/odoo/http.py\", line 1858, in _serve_nodb\n    response = self.dispatcher.dispatch(rule.endpoint, args)\n  File \"/usr/lib/python3/dist-packages/odoo/http.py\", line 2178, in dispatch\n    result = endpoint(**self.request.params)\n  File \"/usr/lib/python3/dist-packages/odoo/http.py\", line 727, in route_wrapper\n    result = endpoint(self, *args, **params_ok)\n  File \"/usr/lib/python3/dist-packages/odoo/addons/base/controllers/rpc.py\", line 178, in jsonrpc\n    return dispatch_rpc(service, method, args)\n  File \"/usr/lib/python3/dist-packages/odoo/http.py\", line 398, in dispatch_rpc\n    return dispatch(method, params)\n  File \"/usr/lib/python3/dist-packages/odoo/service/model.py\", line 37, in dispatch\n    res = execute(db, uid, *params[3:])\n  File \"/usr/lib/python3/dist-packages/odoo/service/model.py\", line 68, in execute\n    res = execute_cr(cr, uid, obj, method, *args, **kw)\n  File \"/usr/lib/python3/dist-packages/odoo/service/model.py\", line 52, in execute_cr\n    result = retrying(partial(odoo.api.call_kw, recs, method, args, kw), env)\n  File \"/usr/lib/python3/dist-packages/odoo/service/model.py\", line 156, in retrying\n    raise _as_validation_error(env, exc) from exc\nodoo.exceptions.ValidationError: The operation cannot be completed: Error, a partner cannot follow twice the same object.\n",
            "message": "The operation cannot be completed: Error, a partner cannot follow twice the same object.",
            "arguments": [
                "The operation cannot be completed: Error, a partner cannot follow twice the same object."
            ],
            "context": {}
        }
    }
}


​

0
Awatar
Odrzuć
Awatar
Christoph Farnleitner
Najlepsza odpowiedź

candidate_id on hr.applicant is defined here:

https://github.com/odoo/odoo/blob/18.0/addons/hr_recruitment/models/hr_applicant.py#L39


Now, when taking a look at the website form for applying to a job, https://github.com/odoo/odoo/blob/18.0/addons/website_hr_recruitment/views/website_hr_recruitment_templates.xml#L206, you can see that Odoo uses a generic form action (/website/form/) to post data to; Thus, the route for it is defined here: https://github.com/odoo/odoo/blob/18.0/addons/website/controllers/form.py.

Now, investigating it further you'll come across a call to _handle_website_form() (line 65 as of today) which does some extract_data() shenanigans.

This extract_data() is then extended in the website specific module for HR Recruitment (https://github.com/odoo/odoo/blob/18.0/addons/website_hr_recruitment/controllers/main.py#L349) in which you then can find the actual creation of such a candidate, based on the form data:

if partner_phone and partner_email:
candidate = request.env['hr.candidate'].sudo().search([
    ('email_from', '=', partner_email),
        ('partner_phone', '=', partner_phone),
    ], limit=1)
if not candidate:
candidate = request.env['hr.candidate'].sudo().create({
    'partner_name': partner_name,
        'email_from': partner_email,
        'partner_phone': partner_phone,
        'company_id': company_id,
})

and finally, a little further down the line, the candidate_id is passed on for using it in the actual hr.applicant record:

if candidate:
data['record']['candidate_id'] = candidate.id



0
Awatar
Odrzuć
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ę
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