Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

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

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
errorhelpunknowncustom_module
1 ตอบกลับ
8461 มุมมอง
อวตาร
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
อวตาร
ละทิ้ง
Hugues Perrier
ผู้เขียน

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 :)

อวตาร
Cybrosys Techno Solutions Pvt.Ltd
คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
Can't change default value of a Custom Model
error default custom_module
อวตาร
0
มี.ค. 25
1334
Issue on Account move lline
error help account.move.line
อวตาร
อวตาร
อวตาร
3
ธ.ค. 23
6734
Module creation issues for v17
development developement error help
อวตาร
อวตาร
อวตาร
3
มิ.ย. 24
3391
Configure the Outgoing Mail Servers: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1007)
error email help configure
อวตาร
อวตาร
อวตาร
2
มิ.ย. 24
3050
Error Upgrade Odoo version 12 to version 16 แก้ไขแล้ว
error help odooV12 odoo16features
อวตาร
อวตาร
1
ก.ค. 23
3307
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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