Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
sale.orderproduct.product
1 Odgovori
11674 Prikazi
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
Opusti
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
Avtor

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
Avtor

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
Best Answer

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Where to find the possible and available models the ORM API provides? Solved
sale.order product.product api.model
Avatar
Avatar
3
okt. 17
7999
Display field only for one company on list view Solved
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 () Solved
sale.order
Avatar
Avatar
Avatar
Avatar
Avatar
4
feb. 24
13455
sale / delivery Solved
sale.order
Avatar
Avatar
1
jan. 24
2224
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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