コンテンツへスキップ
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
このフォーラムについて
ヘルプ

Problem with many2one field in models which inerit res.partner

購読

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

この質問にフラグが付けられました
many2oneinherit
2 返信
17236 ビュー
アバター
ghofrane

Hi all,

I want to add new field (many2one) in form view of res.partner but i got ERROR DataError: invalid input syntax for integer: "default" LINE 1: ...om.id FROM "travel_room" WHERE travel_room.id IN ('default')... :


in my model i create partner.py :

from osv import osv,fields

class partner(osv.osv):

_inherit = 'res.partner'
_columns = {
    'hotel' : fields.boolean('Hotel'),
    'type' : fields.many2one('travel.room', 'type de la chambre', change_default=True, select=True, track_visibility='always', ondelete="cascade"),
}

partner()


and my partner_view.xml :

<openerp> <data> <record model="ir.ui.view" id="partner_hotel_form_view">

    <field name="name">partner.hotel.name</field>
    <field name="model">res.partner</field>  
    <field name="inherit_id" ref="base.view_partner_form" />    
    <field name="arch" type="xml">
   <data>
   <field name="supplier" position="after">
    <field name="hotel" />
   </field>
       <field name="customer" position="after">
    <field name="type" />
   </field>
   </data>
    </field>        
</record>

</data> </openerp>


and here my class travel_room :

class travel_room(osv.osv):

_name = 'travel.room'

_columns = {
    'product_id' : fields.many2one('product.product', 'Type de la chambre', required=True, change_default=True, select=True, track_visibility='always', ondelete="cascade"),
    'name' : fields.related('product_id', 'name', type='char', size=128, string='Product Name'),
    'room_desc' : fields.many2one('product.category', 'Descripcion', required=True, ondelete='cascade'),
    'cost_price' : fields.float('Prix de revient', digits=(6,3), help="Prix de revient"),
    'sale_price' : fields.float('Prix d\'achat', digits=(6,3), help="Prix d'achat"),
}
_defaults = {
}

travel_room()

any one can help me Please! Thank you

1
アバター
破棄
Brett Lehrer

Any reason for the blank _defaults dictionary? What version are you running? You could run the server with the command line option --log-sql to expand on what that full statement is.

ghofrane
著作者

Hi Brett, i'm using version 7 of openerp , I removed the blank _defaults dictionary and I got same error : 2013-05-16 09:14:46,340 6896 ERROR test openerp.sql_db: bad query: SELECT travel_room."product_id",travel_room."sale_price",travel_room."cost_price",travel_room."room_desc",travel_room.id FROM "travel_room" WHERE travel_room.id IN ('default') ORDER BY id Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130331_231656-py2.7.egg/openerp/sql_db.py", line 22

アバター
Brett Lehrer
最善の回答

The problem is that the field 'type' already exists in res.partner. Not normally a big deal, but it's also given default values from the base module, which means that if you inherit res.partner and define 'type' differently but don't change the _defaults dictionary to stop inserting 'contact' or 'default', this error will occur.

Just change the name of your 'type' field to something like 'hotel_type' - it's more explicit and pythonic anyway, but also fixes your problem. Also cleaned up the view a bit for organization so that the hotel_type is hidden when 'hotel' is False.

partner.py: from openerp.osv import osv,fields

class partner(osv.Model):
    _inherit = 'res.partner'
    _columns = {
        'hotel': fields.boolean('Hotel'),
        'hotel_type': fields.many2one('travel.room', 'type de la chambre', change_default=True, select=True, ondelete='cascade'),
    }
partner()

partner_view.xml:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="partner_hotel_form_view">
    <field name="name">partner.hotel.name</field>
    <field name="model">res.partner</field>  
    <field name="inherit_id" ref="base.view_partner_form" />
    <field name="arch" type="xml">
        <data>
            <xpath expr="//group/field[@name='supplier']" position="after">
                <field name="hotel" />
                <field name="hotel_type" attrs="{'invisible': [('hotel','=',False)]}"/>
            </xpath>
        </data>
    </field>
</record>
</data>
</openerp>
0
アバター
破棄
ghofrane
著作者

Thank you very much Brett for your answer but when i add or change any field in partner.py i see this ERROR! 2013-05-16 14:40:46,119 16911 ERROR test openerp.netsvc: column res_partner.hotel_type does not exist LINE 1: ..._partner."debit_limit",res_partner."signup_token",res_partne... it's from yestreday :( Please have you a solution for this Error ?

ghofrane
著作者

Even when i add any other field in my partner.py i get the same Error, i can't understand why ?!

Brett Lehrer

Have you reloaded your module? Changing the field after it's initialized means it needs to be reloaded. Or if that doesn't work, try on a fresh database to see what happens.

ghofrane
著作者

with a fresh database it work! Brett Please can you tell me if there is a possibility to clean the database after i delete any field from .py file ? because every time i delete a field and i check the database with pgadmin3 i see the column named with the that field and with the word _moved1 or _moved_2 ... for example type_moved1 !

ghofrane
著作者

and Thank you very much again :))

Brett Lehrer

I don't think it's possible to automatically do that, since it tends to just ignore unused columns rather than drop them completely. It's fine to leave them in as you're developing and testing, just make a new database and import data once you're ready to move to production. If you really want to drop a column, you'd have to do it manually in pgAdmin through the menus or with this SQL statement format: "ALTER TABLE my_table DROP my_obsolete_field;"

ghofrane
著作者

Thank you Brett for your quick and good answer :)

アバター
ghofrane
著作者 最善の回答

Hi Brett, i'm using version 7 of openerp , I removed the blank _defaults dictionary and I got same error : 2013-05-16 09:14:46,340 6896 ERROR test openerp.sql_db: bad query: SELECT travel_room."product_id",travel_room."sale_price",travel_room."cost_price",travel_room."room_desc",travel_room.id FROM "travel_room" WHERE travel_room.id IN ('default') ORDER BY id Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130331_231656-py2.7.egg/openerp/sql_db.py", line 226, in execute res = self._obj.execute(query, params) DataError: invalid input syntax for integer: "default" LINE 1: ...om.id FROM "travel_room" WHERE travel_room.id IN ('default')...

Please can anyoune help me! i just want to know if it's possible to add field.many2one('my.model') in class which inherit res.partner knowing that 'my.model' contain field.many2one('product.product'). i(m using version 7 of openerp

0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

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

登録
関連投稿 返信 ビュー 活動
many2one field in inherited class ?
many2one inherit
アバター
0
3月 15
4810
value not pass from many2one field to form
many2one
アバター
アバター
アバター
アバター
3
9月 25
2442
Display values of dropdown in a many2one field 解決済
many2one
アバター
アバター
2
2月 25
7083
How to do Prototpye inherit in odoo
inherit
アバター
アバター
アバター
アバター
アバター
4
3月 24
4612
Inheritance for account.financial.report model?
inherit
アバター
アバター
1
10月 23
6577
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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