コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    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:

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

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

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
errorhelpunknowncustom_module
1 返信
8473 ビュー
アバター
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
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Can't change default value of a Custom Model
error default custom_module
アバター
0
3月 25
1340
Issue on Account move lline
error help account.move.line
アバター
アバター
アバター
3
12月 23
6768
Module creation issues for v17
development developement error help
アバター
アバター
アバター
3
6月 24
3400
Configure the Outgoing Mail Servers: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1007)
error email help configure
アバター
アバター
アバター
2
6月 24
3061
Error Upgrade Odoo version 12 to version 16 解決済
error help odooV12 odoo16features
アバター
アバター
1
7月 23
3311
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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