Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • 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
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
productsale.order.linevariantattributeodooV8
2 Replies
8213 Views
Avatar
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
Avatar
Discard
Avatar
Herman
Author Best Answer

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
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Product label prints only one variant attribute
product label variant attribute
Avatar
Avatar
2
मार्च 16
7021
Difficulty creating product variants using API in PHP [12.0]
product api php variant attribute
Avatar
2
जन॰ 20
5184
What is the easier way to select a product variant in a sale order?
product sale order variant attribute
Avatar
Avatar
1
जुल॰ 24
6222
Could we define a multi dimensional « attribute price extra »?
product price variant attribute extra
Avatar
0
सित॰ 15
5300
How is it added a new field in XML specifying on_change attribute at the same time? Solved
fields xml sale.order.line attribute odooV8
Avatar
Avatar
1
जुल॰ 15
4712
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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