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

Odoo 8 Select Product and Variant in seperate fields in Sales order

購読

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

この質問にフラグが付けられました
productsale.order.linevariantattributeodooV8
2 返信
8216 ビュー
アバター
Herman

Hi there fellow developers

in Odoo 8's product.py I see the name_search method concatenates the product name and variant as the product name. I however have hundreds of attributes to my product.

Height: 500mm, 505mm, ... 3000mm

Width: 500mm, 505mm, ... 4000mm

So it makes it impossible to search the desired variant

So i need first select the product, Then the Height attribute, Then the Width attribute

In Theory I need to override the search method

  • remove the variant in product name

  • create a search method to select first attribute

  • create another search method to select second attribute

  • then it needs to return the product name + att1 + att2 to main search method

Can anyone point me in the right direction?

I really need some serious assistance. Speak to me about cash for code if really neccesary :)


My .py


from openerp import models, fields, api

class product_template(models.Model):

      _inherit = 'product.template'

      palepoint = fields.Char("Pale Point", size=20)

      materialoptions_id = fields.Many2one("product.category","Material Options")

class Sale_order(models.Model):

      _inherit = 'sale.order'

      material_id= fields.Many2one("product.template","Material",domain=[('categ_id.name','=','Raw Material')])

class product_product(models.Model):

      _inherit = 'product.product'

     #This search filter the products by selected product category which works fine

      def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):

          if context is None:

              context = {}

          if context.get('material_id'):

              productobj = self.pool.get('product.product').read(cr, uid, context['material_id'],['materialoptions_id'])

              args = [('categ_id','=',productobj['materialoptions_id'][0])] + args

              return super(product_product, self).search(cr, uid, args, offset, limit, order, context=context, count=count)

My view


<openerp>

      <data>

          <record model="ir.ui.view" id="partner_palepoint_form_view">

              <field name="model">product.template</field>

              <field name="inherit_id" ref="product.product_template_only_form_view"/>

              <field name="arch" type="xml">

              <field name="list_price" position="after">

              <field name="materialoptions_id"/>

              </field>

              <notebook position="inside">

                  <page string="Pale Point">

                      <group>

                          <field name="palepoint"/>

                      </group>

                  </page>

                 </notebook>

              </field>

          </record>

          <record model="ir.ui.view" id="sale_view_form_view">

              <field name="model">sale.order</field>

              <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>

              <field name="arch" type="xml">

                  <field name="partner_id" position="after">

                      <field name="material_id"/>

              </field>

              <xpath expr="//field[@name='product_id']" position="attributes">

                  <attribute name="context">{'material_id': parent.material_id}</attribute>

              </xpath>

              </field>

          </record>

      </data>

</openerp>



And good old Odoo 8's product.py nam_search method


def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):

# Only use the product.product heuristics if there is a search term and the domain

# does not specify a match on `product.template` IDs.

if not name or any(term[0] == 'id' for term in (args or [])):

return super(product_template, self).name_search(

cr, user, name=name, args=args, operator=operator, context=context, limit=limit)

product_product = self.pool['product.product']

results = product_product.name_search(

cr, user, name, args, operator=operator, context=context, limit=limit)

product_ids = [p[0] for p in results]

template_ids = [p.product_tmpl_id.id

for p in product_product.browse(

cr, user, product_ids, context=context)]

# re-apply product.template order + name_get

return super(product_template, self).name_search(

cr, user, '', args=[('id', 'in', template_ids)],

operator='ilike', context=context, limit=limit)


0
アバター
破棄
アバター
Herman
著作者 最善の回答

So what I think the best "Work Around" would be is if I create 3 custom fields

  • Product Type (All the product names in selected category)

  • Width (attributes linked to product selected in 'Product Type')

  • Height (attributes linked to product selected in 'Product Type')

above the product field. Then by concatenating those 3 values I can pass the context 'name' to the product search method to match. Therefore only displaying one product matching the criteria above

Hope this helps -me-

Why is this the best way? probably shouldve added this. educational value and what not.

Because, whilst debugging you'll see the product and it's attribute shares an id. That is because odoo treats each product variant as a product. There's no "main" product and then it's child variants. It's one in the same.


LOOK HERE===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]
LOOK HERE2===================================================
{'default_code': False, 'id': 33, 'name': u'Palisade Fence (Domestic 110mm) (1800, 3000mm)'}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]
LOOK HERE2===================================================
{'default_code': False, 'id': 34, 'name': u'Palisade Fence (Domestic 110mm) (1800, 3005mm)'}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]
LOOK HERE2===================================================
{'default_code': False, 'id': 35, 'name': u'Palisade Fence (Domestic 110mm) (1805, 3000mm)'}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]

Which is why each variant has it's own Bill of materials (Which is exactly what i need, Thank you brilliant odoo developers) So unless you want to change the structure of odoo, you first need to pass a context to filter the products, not the other way around

Hope this makes sense everyone. I'm VERY new to programming so please tell me if I'm missing the plot.

odoo is INCREDIBLE thanks guys

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

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

登録
関連投稿 返信 ビュー 活動
Product label prints only one variant attribute
product label variant attribute
アバター
アバター
2
3月 16
7022
Difficulty creating product variants using API in PHP [12.0]
product api php variant attribute
アバター
2
1月 20
5188
What is the easier way to select a product variant in a sale order?
product sale order variant attribute
アバター
アバター
1
7月 24
6222
Could we define a multi dimensional « attribute price extra »?
product price variant attribute extra
アバター
0
9月 15
5302
How is it added a new field in XML specifying on_change attribute at the same time? 解決済
fields xml sale.order.line attribute odooV8
アバター
アバター
1
7月 15
4713
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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