Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

AttributeError: '_unknown' object has no attribute 'id'

Odebírat

Get notified when there's activity on this post

This question has been flagged
errorhelpunknowncustom_module
1 Odpovědět
8457 Zobrazení
Avatar
Hugues Perrier

Hello, 

I'm on odoo 15 and I'm trying to create a custom module, but I have an error that I can't fix:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 910, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1326, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1318, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 6507, in onchange
result['value'] = snapshot1.diff(snapshot0, force=first_call)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 6331, in diff
result[name] = field.convert_to_onchange(self[name], record, {})
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2845, in convert_to_onchange
return super().convert_to_onchange(value._origin, record, names)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 868, in convert_to_onchange
return self.convert_to_read(value, record)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2821, in convert_to_read
return value.id
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: '_unknown' object has no attribute 'id'

Here is the model : 

from email.policy import default
from odoo import models, fields, api, tools
from odoo.tools import date_utils, email_re, email_split, is_html_empty
from odoo.addons.phone_validation.tools import phone_validation
from datetime import date, datetime, timedelta

class WeglioProspect(models.Model):
# ---------------------------------------- Private Attributes ---------------------------------

_name = "weglio.prospect"
_description = "School prospection by Weglio"

# --------------------------------------- Fields Declaration ----------------------------------

prospect_note = fields.Html("Annotation prospect")
admission_step = fields.Selection([
('nouveau', 'Nouveau'),
('relancer', 'Relancer'),
('refusé', 'Refusé'),
('reporté', 'Reporté'),
('session d’admission', 'Session d’admission'),
('absent en session d’admission', 'Absent en session d’admission'),
('coaching', 'Coaching'),
('admis', 'Admis'),
('eleve', 'Eleve')], "Etape d'admission", required=True, default='nouveau')

# ---------------------------------------------- Contact information need to copy in contact module ------------------------------------------------
civility = fields.Selection([
('monsieur', 'Monsieur'),
('madame', 'Madame'),
('autre', 'Autres')], "Civilité", track_visibility='onchange')
name = fields.Char(required=True)
email = fields.Char("Mail", required=True)
phone = fields.Char("Téléphone", required=True)
# ------------------- Adresse ---------------------
street = fields.Char() # "Adresse"
city = fields.Char() # "Ville"
zip = fields.Char() # "Code Postal"
country_id = fields.Many2one('res.country') # "Pays"
# ------------------- Info naissance ---------------------
date_birth = fields.Date("Date de naissance")
city_birth = fields.Char("Ville de naissance")
country_birth = fields.Many2one('res.country', 'Pays de naissance')

# ---------------------------- Info ----------------------------
source_id = fields.Many2one('utm.source', "Source")
nationality = fields.Many2one('res.country', 'Nationalité')
vital_card = fields.Char("Carte Vital", track_visibility='onchange')
social_system = fields.Selection([('urssaf', 'URSSAF'),
('msa', 'MSA')], 'Régime social')
sport = fields.Selection([('oui', 'Oui'),
('non', 'Non')], 'Sportif')
handicap = fields.Selection([('oui', 'Oui'),
('non', 'Non')], 'Handicape')
situation_before = fields.Selection([('scolaire', 'Scolaire'),
('prepa', 'Prépa'),
('apprentissage', 'Apprentissage'),
('etudiant', 'Etudiant'),
('contrat apprentissage', 'Contrat d\'apprentissage'),
('contrat de professionnalisation', 'Contrat de professionnalisation'),
('contrat aide', 'Contrat aidé'),
('cfa avant signature contrat apprentissage',
'CFA avant signature d\'un contrat d\'apprentissage'),
(
'cfa sans contrat suite à une rupture', 'CFA sans contrat suite à une rupture'),
('stagiaire formation professionnelle', 'Stagiaire formation professionnelle'),
('salarie', 'Salarié'),
('recherche un emploi', 'recherche d\'un emploi'),
('inactif', 'Inactif')], 'Situation avant') # voir avec Guillaume
last_degree = fields.Char('Dernier diplôme préparé')
last_class = fields.Char('Derniere classe') # voir avec Guillaume
# ------------------- Info suivi ---------------------
date_last_raise = fields.Date('Dernière relance')
count_last_raise = fields.Integer('Nombre de relance', compute="_compute_raise_date")

date_previous_raise = fields.Date('Dernière relance')
count_previous_raise = fields.Integer('Nombre de relance')

active = fields.Boolean(string='Actif', default=True)
# ------------------- Document ---------------------
curriculum = fields.Binary("CV", help="Déposer votre cv")
cv_name = fields.Char(compute="_compute_cv_name") # Nom du fichier upload

motivation_letter = fields.Binary("Lettre de motivation", help="Déposer votre lettre de motivation")
motivation_name = fields.Char(compute="_compute_motivation_letter_name") # Nom du fichier upload

upload_test = fields.Binary("Test d'admission", help="Déposer votre test d'admission")
upload_admission_file = fields.Binary("Dossier d'admission", help="Déposer votre Dossier d'admission")
# ------------------- Après être admis ---------------------
company_status = fields.Selection([
('avec entreprise', 'Avec entreprise'),
('a placer en entreprise', 'A placer en entreprise'),
('doit trouver une entreprise', 'Doit trouver une entreprise')], "Status d'admission entreprise")
contract_status = fields.Selection([
('contrat en cours', 'Contrat en cours'),
('interruption contrat', 'Interruption contrat'),
('stagiaire de la formation', 'Stagiaire de la formation')], "Status du contrat")
# Faire la vue des champs ci-dessous

admission_file_complet = fields.Boolean()
wait_doc = fields.Boolean()

# ------------------------- Fields Other Module Declaration ---------------------------

# Permet de définir si la liste affiche uniquement les leads ou les entreprises
company_id = fields.Many2one('res.company', string='Entreprise', domain=[('is_company', '=', True)])
formation_id = fields.Many2one('weglio.formation', string='Formation souhaité')
partner_id = fields.Many2one('res.partner', string='Nom, Prenom', domain=[('is_company', '=', False)])
# domain permet de preselectionner entreprise lors de la création de celle ci
session_re_ids = fields.Many2many('calendar.event', 'weglio_prospect_event_1_rel', 'id', 'event_id', string="Recrutement", domain="[('session_type', '=', 'recrutement')]")
session_co_ids = fields.Many2many('calendar.event', 'weglio_prospect_event_2_rel', 'id', 'event_id', string="Coaching", domain="[('session_type', '=', 'coaching')]")

recrutement_names = fields.Char(string="Recrutement", compute="_compute_session_re_ids_names")
coaching_names = fields.Char(string="Coaching", compute="_compute_session_co_ids_names")

# ------------------------------------- Statistique ----------------------------------------------
# ------------------------------------- Onchange simple ----------------------------------------------
def _onchange_company(self):
if self.admission_step != "admis":
self.company_status = ""
self.company_id = ""

@api.onchange("admission_file_complet", "admission_step")
def _onchange_admssion(self):
if self.admission_file_complet:
self.admission_step = "admis"

# ------------------------------------- Compute simple ----------------------------------------------

@api.depends('session_re_ids')
def _compute_session_re_ids_names(self):
for prospect in self:
prospect.recrutement_names = ', '.join(prospect.session_re_ids.mapped('name'))

@api.depends('session_co_ids')
def _compute_session_co_ids_names(self):
for prospect in self:
prospect.coaching_names = ', '.join(prospect.session_co_ids.mapped('name'))

@api.depends('cv_name', 'partner_id', 'curriculum')
def _compute_cv_name(self):
if self.curriculum:
for each in self:
each.cv_name = "CV_" + each.partner_id.name
else:
self.cv_name = ""

@api.depends('motivation_name', 'partner_id', 'motivation_letter')
def _compute_motivation_letter_name(self):
if self.motivation_letter:
for each in self:
each.motivation_name = "motivation_letter_" + each.partner_id.name
else:
self.motivation_name = ""

@api.depends('partner_id')
def _compute_contact_to_name(self):
if self.name != "":
for each in self:
each.name = "Opportunité : " + each.partner_id.name
else:
each.name = "Opportunité : Anonyme"

@api.onchange('date_last_raise')
def onchange_date_derniere_relance(self):
if self.date_last_raise:
self.admission_step = 'relancer'

# Permet l'archivage des leads
def toggle_archive(self):
for record in self:
record.is_archived = not record.is_archived

# Permet +1 le nombre de relance
@api.depends('date_last_raise', 'count_last_raise')
def _compute_relance_date(self):
for record in self:
if record.date_last_raise != record.date_previous_relance:
record.count_last_raise = record.count_previous_raise + 1
else:
record.count_last_raise = record.count_previous_raise

record.date_previous_raise = record.date_last_raise
record.count_previous_raise = record.count_last_raise


If anyone has an idea, I'm a taker.
Best regards

0
Avatar
Zrušit
Hugues Perrier
Autor

Hello, 

Thank you very much for your help, I found the cause. It's the source_id variable that causes a problem, I think it's because I didn't import the corresponding module in the manifest.py

Or I made a mistake here : source_id = fields.Many2one('utm.source', "Source")

Have a nice day :)

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

There are several reasons to get the error “unknown object has no attribute id

->If we add a many2one field , for example

product_id = fields.Many2one(‘product.product’ string=’Product’)

But we didn’t add ‘product’ on 'depends' in the manifest file,and then we got the error.

->If define a Many2one field without a model, ie, for example

Product_id = fields.Many2one(string=’Product’)

->When we pass wrong data types , for example

field_name = fields.Many2one('partner_id.phone', string=’ Number', readonly=True)

Here the field phone is a Char field , but we give the field type is Many2one

1
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Can't change default value of a Custom Model
error default custom_module
Avatar
0
bře 25
1329
Issue on Account move lline
error help account.move.line
Avatar
Avatar
Avatar
3
pro 23
6725
Module creation issues for v17
development developement error help
Avatar
Avatar
Avatar
3
čvn 24
3389
Configure the Outgoing Mail Servers: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1007)
error email help configure
Avatar
Avatar
Avatar
2
čvn 24
3047
Error Upgrade Odoo version 12 to version 16 Vyřešeno
error help odooV12 odoo16features
Avatar
Avatar
1
čvc 23
3305
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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