Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
errorhelpunknowncustom_module
1 Odpoveď
8471 Zobrazenia
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šiť
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
Best Answer

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šiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Can't change default value of a Custom Model
error default custom_module
Avatar
0
mar 25
1339
Issue on Account move lline
error help account.move.line
Avatar
Avatar
Avatar
3
dec 23
6758
Module creation issues for v17
development developement error help
Avatar
Avatar
Avatar
3
jún 24
3398
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
jún 24
3058
Error Upgrade Odoo version 12 to version 16 Solved
error help odooV12 odoo16features
Avatar
Avatar
1
júl 23
3310
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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