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

[8] how to add field in a view from another?

購読

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

この質問にフラグが付けられました
viewsfieldsproduct.productpurchase.orderproduct.template
3 返信
5598 ビュー
アバター
mauro anelli

hello,

1)i made some custom field in product.template, now i would like to get them in purchase order form view. any help?

2)it's possible to add the value of the field after another? for example i have product id, name, default_code ecc on product.template.product.form. now i would like that in purchase order, when i select a product , it fill the description with name+default_code


thanks

0
アバター
破棄
アバター
Nikhil Krishnan
最善の回答

Hi aneli,
Its possible, 

In purchase module there is function

class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty,
uom_id, partner_id, date_order=False,
fiscal_position_id=False, date_planned=False,
name=False, price_unit=False, state='draft',
context=None):
res = super(PurchaseOrderLine, self).onchange_product_id(
cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id,
date_order=date_order, fiscal_position_id=fiscal_position_id,
date_planned=date_planned, name=name, price_unit=price_unit,
state=state, context=context)
         product_id = res['product_id']
         res['name'] = product_id.name + product_id.default_code
         # for addind  "x_IDfornitore" and x_IDfornitore2 fields
          res['name'] = product_id.name (if needed,) + product_id.x_IDfornitore + IDfornitore2
return res

** Please remove (if needed,) from code.

Please super this function and make what you want.

This is just a model, you can make it as you like. (Don't follow the exact code, its model)

If you need a correct code, you make your question more detailed.

Thank you, hope it will help you.

1
アバター
破棄
アバター
mauro anelli
著作者 最善の回答

thanks very much and sorry but i'm really newbi to programmin.


when i get to change the code i found that the code you gave me is for odoo 9. in odoo 8 i found this

class purchase_order_line(osv.osv):

    def _calc_line_base_price(self, cr, uid, line, context=None):

        """Return the base price of the line to be used for tax calculation.

        This function can be extended by other modules to modify this base

        price (adding a discount, for example).

        """

        return line.price_unit

    def _calc_line_quantity(self, cr, uid, line, context=None):

        """Return the base quantity of the line to be used for the subtotal.

        This function can be extended by other modules to modify this base

        quantity (adding for example offers 3x2 and so on).

        """

        return line.product_qty

    def _amount_line(self, cr, uid, ids, prop, arg, context=None):

        res = {}

        cur_obj=self.pool.get('res.currency')

        tax_obj = self.pool.get('account.tax')

        for line in self.browse(cr, uid, ids, context=context):

            line_price = self._calc_line_base_price(cr, uid, line,

                                                    context=context)

            line_qty = self._calc_line_quantity(cr, uid, line,

                                                context=context)

            taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line_price,

                                        line_qty, line.product_id,

                                        line.order_id.partner_id)

            cur = line.order_id.pricelist_id.currency_id

            res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])

        return res

    def _get_uom_id(self, cr, uid, context=None):

        try:

            proxy = self.pool.get('ir.model.data')

            result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')

            return result[1]

        except Exception, ex:

            return False

    _columns = {

        'name': fields.text('Description', required=True),

        'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),

        'date_planned': fields.date('Scheduled Date', required=True, select=True),

        'taxes_id': fields.many2many('account.tax', 'purchase_order_taxe', 'ord_id', 'tax_id', 'Taxes', domain=['|', ('active', '=', False), ('active', '=', True)]),

        'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),

        'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),

        'move_ids': fields.one2many('stock.move', 'purchase_line_id', 'Reservation', readonly=True, ondelete='set null'),

        'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),

        'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Account')),

        'order_id': fields.many2one('purchase.order', 'Order Reference', select=True, required=True, ondelete='cascade'),

        'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account',),

        'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),

        'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')],

ecc ecc


it's similar or i need to write a different code?


thank

0
アバター
破棄
Nikhil Krishnan

Hai friend, i think In the XML you did not make any change, so you need to add this 2 values( "x_IDfornitore" and x_IDfornitore2) in name field in purchase order,

So you just check my above answer once more, i will rewrite it for you, please check that this fields ( "x_IDfornitore" and x_IDfornitore2) defined in product.template. ok

mauro anelli
著作者

i'm sorry but the function you gave me is in the purchase.py from odoo 9. i change my answare with the code i found in odoo 8 versione of purchase.py. i don't if it's the same

mauro anelli
著作者

on odoo 8 this function "class PurchaseOrderLine(models.Model)" is different . it's purchase_order_line(osv.osv) ecc. the code still works or i need a different one?

thanks

アバター
Rafael Aguero Baquero
最善の回答

Of course it's possible. You need to make an inheritance of purchase.order.line for rewrite the onchange_product_id method, in this method you can put into description field anything you want.

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

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

登録
関連投稿 返信 ビュー 活動
isn't standard_price must be depend on the product.product?
fields product.product prices product.template
アバター
アバター
1
12月 15
4714
Add purchase order field to product template
fields odoo api.depends purchase.order product.template
アバター
アバター
1
8月 23
2994
How to add a field in product.product after made some changes in product template ?
v8 fields inherit product.product product.template
アバター
アバター
1
11月 15
12230
What is the way that product.product and product.template synchronize data? 解決済
product.product product.template
アバター
アバター
アバター
2
8月 23
6142
Making a variantproduct from existing product templates
product.product product.template
アバター
0
10月 21
2377
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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