Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Missing understanding

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
2 Réponses
991 Vues
Avatar
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
Avatar
Ignorer
Bernhard Marx
Auteur

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

Avatar
Bernhard Marx
Auteur Meilleure réponse

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
Avatar
Ignorer
Avatar
Christoph Farnleitner
Meilleure réponse

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
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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