Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

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

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
productsale.order.linevariantattributeodooV8
2 Risposte
8221 Visualizzazioni
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
Abbandona
Avatar
Herman
Autore Risposta migliore

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
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Product label prints only one variant attribute
product label variant attribute
Avatar
Avatar
2
mar 16
7023
Difficulty creating product variants using API in PHP [12.0]
product api php variant attribute
Avatar
2
gen 20
5191
What is the easier way to select a product variant in a sale order?
product sale order variant attribute
Avatar
Avatar
1
lug 24
6223
Could we define a multi dimensional « attribute price extra »?
product price variant attribute extra
Avatar
0
set 15
5304
How is it added a new field in XML specifying on_change attribute at the same time? Risolto
fields xml sale.order.line attribute odooV8
Avatar
Avatar
1
lug 15
4714
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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