Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Setup filter in Sales Order "Add An Item" search view

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
sale.orderproduct.product
1 Svar
11671 Visninger
Avatar
Jae Landers

I am trying to setup a filter that will base itself off of the "Customer" field (partner_id) when creating or modifying a Sales Order. I am very new to OpenERP, so please pardon any obvious mistakes.

I made the following line in the search view to create the filter:

<filter string="Customers Items" domain="[('x_whereused','=',sale.view_order_form.partner_id)]" name="own_area_items"/>

x_whereused is a custom field I made in product.template which indicates which customers use what parts. I want the Add an Item - Search More view to have the above filter compare the partner_id in the newly made Sales Order with my custom field (x_whereused) and display if it matches. I get the following error currently when applying the filter.
 

"TypeError: context is undefined

http://_________/web/js.web.assets_backend/7b7a275:3778"

Thanks very much for any assistance on this!

1
Avatar
Kassér
john5000

Hi Kyle, you should change your "answer" below to a comment to my answer. Click the "Convert as comment" to do that. You may have to also copy-paste it as a comment to my answer. Also, click the grey circled checkmark on my answer to "accept" it.

john5000

And I'm checking out how to answer your further question...

Jae Landers
Forfatter

Thanks! I'm definitely going to try that out. One question I have is in the case that I wanted the user to be able (if they wanted) to go through the other listings that are not matching the x_whereused field (say the item is not in the list and the sales man wants to check for something not necessarily associated with that customer), would they be able to do this with the above code in place? Please excuse me if I'm mis-understanding, but from what I can tell, the code you gave will filter the results regardless of filters being applied in the search window itself. My idea came up from observing the "My" filter in th Draft Quotations view, that shows your own drafts, and then if you remove it, it shows everyone's. Thanks and Happy New Year!

john5000

Hello. I follow what you are asking for. Unfortunately I've not found out how to do that. The domain puts a filter there, which is not shown to the user. Normally you use default_search_(field) to set a default that is shown as a search filter to the user. But that is not made for doing a lookup on a many2one within a form. So, at this point it is probably best to work out the other parts of your system and then come back to this when you have a better understanding of the various capabilities.

Jae Landers
Forfatter

Well, been a long time coming but I finally ended up revisiting this and got your code implemented in a module. I decided to ditch the optional part of seeing another customers parts as that can be done in the product menu, doesn't need to done in the sales order. The final code I ended up using is: sale.view.order.form.inherit sale.order <xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="attributes"> [('whereused','=',parent.partner_id)]

Avatar
john5000
Bedste svar

You can't use "sale.view_order_form.partner_id" in your filter, as the search view will not be able to understand it.

Also the filter needs to be part of the product lookup with in the sales order form.

Here is how you can add a filter to the products listing in a sales order:

And in your case the partner_id will be used as the id to filter with. 

Add the following to the product_id field view defintion:

   domain="[('x_whereused', '=', parent.partner_id)]"

You will find an example of the xpath section for doing this in the file "sale_stock_view.xml" (under the "sales" addon folder)
Look for the following section, which is the xpath section that needs to be modified:

<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="replace" 
    <field name="product_id
        domain="[('x_whereused', '=', parent.partner_id)]"             <-- Add this
        context=... (etc.)
        ...    />
</xpath>

You should of course put this this in your own addon that is used to override the exiting logic (hopefully you are doing that).

But if you just want to see it in action quickly, you can add that line above to the "sale_stock_view.xml" file, then under Settings->Apps find the "Sales Management" and do "Upgrade".

Now when you create an order and click on the product field it will be filtered by the partner_id.  Of course, you can change that domain= to filter by other criteria also. 

1
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Where to find the possible and available models the ORM API provides? Løst
sale.order product.product api.model
Avatar
Avatar
3
okt. 17
7998
Display field only for one company on list view Løst
sale.order
Avatar
Avatar
1
maj 25
1766
Sale order Balance
sale.order
Avatar
Avatar
Avatar
2
nov. 24
2822
Mark a sales order as fully invoiced despite Order amount and invoiced amount do not match () Løst
sale.order
Avatar
Avatar
Avatar
Avatar
Avatar
4
feb. 24
13455
sale / delivery Løst
sale.order
Avatar
Avatar
1
jan. 24
2224
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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