Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

Search options are not getting refined. (Coding problem)

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
searchcontext
3955 Ansichten
Avatar
Arjun Khode

I'm trying to implement a boat company module.

I have various boats, and each boat has model options, like engine names, etc.

In my sale.order module, I have extended the module to be able to enter boat name

In the Order Lines page of that form, I have an option to select the model options relevant to that boat name. And I'm trying to implement a search function that refines the results of that drop down to only the models of that particular boat's id we just selected above.

I wrote the function but it's not working for some reason. Can you please help me out?

Here are the relevant files:

XML:

<record id="sale_view_order_form" model="ir.ui.view">
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <field name="partner_id" position="after">
                    <field name="boatmodel_id"/>            
                </field>
                <xpath expr="//field[@name='product_id']" position="attributes">
                    <attribute name="context">
                        {'boatmodel_id': parent.boatmodel_id}
                    </attribute>
                </xpath>
            </field>
        </record>

PY:

class product_template(osv.osv):
    _inherit="product.template"
    _columns={
              'boatlength':fields.char("Boat Length", size=18),
              'fuelcapacity':fields.char("Fuel Capacity", size=18),
              'modeloptions_id':fields.many2one("product.category","Model Options"),
              
              }
    
    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
        print("Hii Search has started")
        if context is None:
            print("Heloo context was none")
            context={}
        if context.get('boatmodel_id'):
            print("CONTEXT========")
            print context['boatmodel_id']
            #code to limit by category assigned to the boat model
            productobj=self.pool.get('product.template').read(cr, uid, context['boatmodel_id'],['modeloptions_id'])
            args=[('categ_id','=',productobj['modeloptions_id'][0])] + args
        return super(product_template, self).search(cr, uid, args, offset, limit, order, context=context, count=count)
            
                
class sale_order(osv.osv):
    _inherit="sale.order"
    _columns={
              'boatmodel_id':fields.many2one("product.template","Boat Model", domain=[('categ_id.name','=','Boat Models')]),
              
              }

Note:As you may have noticed, I have written print statements to test the outputs of the search function on the console. But nothing ever gets printed. I guess the search function never gets called. I'm using Odoo 8

0
Avatar
Verwerfen
Mansi Kariya (mka)

Its obvious that your search method will not be called as you are calling and checking method of product_template and you have updated product_id's context which is of product_product. so when making change in product_product will not call search method of product_template.

Arjun Khode
Autor

Thanks for pointing it out. Can you suggest a way how I can keep things within product_template and implement the same functionality? Is there anything else I can use instead of product_id ?

Mansi Kariya (mka)

But why are you changing template. According to me you are going wrong. instead you need to add this fields to product_product, Any ways its up requirements, But if you maintain though product_product it would be easy and well maintained.

Arjun Khode
Autor

Ok. I will try rewriting the code in product_product :)

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
what I should put in the search([ ]) to match date in different model/database?
search context calculation
Avatar
Avatar
Avatar
6
März 18
8761
context.get not working in xml search filter domain Gelöst
search context domain_filter
Avatar
1
Mai 16
10167
Context: function never called - need help
python search context
Avatar
0
Mai 15
3716
many2one search context
many2one search context
Avatar
Avatar
2
März 15
8501
How do I filter a spreadsheet pivot to the current/previous month
search
Avatar
Avatar
1
Juli 25
1462
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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