Sari la conținut
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
    • Property Management
    • 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
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Suport

Missing understanding

Abonare

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

Această întrebare a fost marcată
2 Răspunsuri
1056 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
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

Imagine profil
Bernhard Marx
Autor Cel mai bun răspuns

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

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
Imagine profil
Abandonează
Îți place discuția? Nu doar citi, alătură-te!

Creează-ți un cont astăzi pentru a beneficia de funcții exclusive și a interacționa cu minunata noastră comunitate!

Înscrie-te
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 Svenska ภาษาไทย 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